By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,339 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,339 IT Pros & Developers. It's quick & easy.

ADO-SQL LIKE

P: n/a
Hey.

Using Access ADP and MSDE.

can some one please tell me what is wrong with this SQL string using
ADO. I get an error somewhere around the LIKE statement.

.Source = "SELECT tblCustomer.FirstName,
tblCustomer.LastName, tblCustomer.PostCode " & _
"FROM tblCustomer " & _
"WHERE (FirstName LIKE '%" &
Form("txtSearchFirstName") & "%');"
Thanks a lot.
GAVO

Nov 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
My guess is that there is something wrong with
Form("txtSearchFirstName")
as I have tested your syntax and it seems to work.
What is Form? Do you mean Me.txtSearchFirstName.Value or
Me.txtSearchFirstName.Text? Could you use just txtSearchFirstName?
Could Me.txtSearchFirstName.Value be NULL?

I would try
debug.print "SELECT tblCustomer.FirstName,
tblCustomer.LastName, tblCustomer.PostCode " & _
"FROM tblCustomer " & _
"WHERE (FirstName LIKE '%" &
Form("txtSearchFirstName") & "%');"
and examine the string carefully.

Nov 23 '05 #2

P: n/a
Thanks Lylefair.
The code was fine, the problem was that I was running the code from a
"onClick" on a label and thefore the text box "txtSearchFirstName"
never lost its focus and I believe did not save the value, so what I
did is, I set the focus on a different control before running the SQL
and its now working.

Thanks

Nov 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.