code:
Private Sub Combo58_AfterUpdate()
Dim intPictureYear As String
intPictureYear = DLookup("SportYear", "Sport", _
"SportCode=" & Me!Combo58)
End Sub
can someone please tell me what this means
>The below code has given me the following error
>The expression you entered as a query parameter produced this error: 'M'
>
>code:
>Private Sub Combo58_AfterUpdate()
>Dim intPictureYear As String
>
>intPictureYear = DLookup("SportYear", "Sport", _
> "SportCode=" & Me!Combo58)
>
>End Sub
That usually means that the SportCode field is a text field
and that you need to enclose the value in quotes:
"SportCode='" & Me!Combo58) & "' "
--
Marsh
MVP [MS Access]
strCode = Me.Combo58
intPictureYear = DLookup("SportYear", "Sport", "SportCode=" & "'strCode'")
I have a feeling the strcode is not being passed correctly and the lookup is
coming up with a null value because it can't access the record
>yes you are absolutely correct. i corrected the code by adding but now I get
>an invalid use of null error.
>
>strCode = Me.Combo58
>intPictureYear = DLookup("SportYear", "Sport", "SportCode=" & "'strCode'")
>
>I have a feeling the strcode is not being passed correctly and the lookup is
>coming up with a null value because it can't access the record
Your feeling is correct, but your translation of my
suggested code is not ;-)
. . . , "SportCode='" & strCode & "' ")