Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dlookup question 2

Status
Not open for further replies.

jgarnick

Programmer
Feb 16, 2000
189
US
Does anyone know why I would get a &quot;data type mismatch in criteria expression&quot; error from the dlookup statement below?&nbsp;&nbsp;Macyear is a text field in the underlying table that the query &quot;artwrk macnum&quot; is based on and it is also a text field on the open form.&nbsp;&nbsp;Any ideas?<br><br>Private Sub Command55_Click()<br>Dim varx As Variant<br>varx = DLookup(&quot;[maxofmacextension]&quot;, &quot;artwrk macnum&quot;, &quot;[macyear] =&quot;& me![macyear])<br>End Sub<br><br>Thanks! <p>jgarnick<br><a href=mailto:jgarnick@aol.com>jgarnick@aol.com</a><br><a href= > </a><br>
 
If me![macyear] is a text expression, it seems that it should be enclosed in single quotes, ie.:<br><br>varx = DLookup(&quot;[maxofmacextension]&quot;, &quot;artwrk macnum&quot;, &quot;[macyear] ='&quot;& me![macyear]&&quot;'&quot;)<br><br>HTH,<br>Drew
 
That worked!!&nbsp;&nbsp;I must have tried every other syntax, except for that one. Thanks a bunch!! <p>jgarnick<br><a href=mailto:jgarnick@aol.com>jgarnick@aol.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top