Query Criteria for Access 2003

M

Mike W

I am trying to use the LIKE function in a query to match the first two
letters of a combo box on my selection form to a table field. I have not
been eable to correct the syntax for this. The following does NOT work:
Like"??[forms]![formname]![comboboxname]". Any ideas?

Thanks
Mike
 
D

Douglas J Steele

In the Criteria cell in the Query Builder:

LIKE Left([forms]![formname]![comboboxname], 2) & "*"


In VBA:

strSQL = "SELECT .... FROM .... " & _
" WHERE Field LIKE " & Chr$(34) & _
Left([forms]![formname]![comboboxname], 2) & "*" & Chr$(34)
 
M

Mike W

Douglas;

Thanks for the input, that works great. I'd been struggling with this most
of the morning.

Mike

Douglas J Steele said:
In the Criteria cell in the Query Builder:

LIKE Left([forms]![formname]![comboboxname], 2) & "*"


In VBA:

strSQL = "SELECT .... FROM .... " & _
" WHERE Field LIKE " & Chr$(34) & _
Left([forms]![formname]![comboboxname], 2) & "*" & Chr$(34)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Mike W said:
I am trying to use the LIKE function in a query to match the first two
letters of a combo box on my selection form to a table field. I have not
been eable to correct the syntax for this. The following does NOT work:
Like"??[forms]![formname]![comboboxname]". Any ideas?

Thanks
Mike
 
Top