Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dlookup error message 'M'

0 views
Skip to first unread message

Tknows

unread,
Nov 18, 2007, 5:32:02 PM11/18/07
to
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

can someone please tell me what this means

Marshall Barton

unread,
Nov 18, 2007, 6:46:23 PM11/18/07
to
Tknows wrote:

>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]

Tknows

unread,
Nov 18, 2007, 9:23:00 PM11/18/07
to
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

Marshall Barton

unread,
Nov 18, 2007, 10:42:24 PM11/18/07
to
Tknows wrote:

>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 & "' ")

0 new messages