Like SQL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to search a memo field and find all records with a specific date
somewhere in the comments...search_date below is defined as a "date"

Dim temp_search_date As String
temp_search_date = search_date
Set leads = dbCDMi.OpenRecordset _
("SELECT comments from leads_cdmi where comments like %" & temp_search_date
& "%", dbOpenForwardOnly)

why doesn't this work? I get an error message saying

3075
Syntax error in query expression 'comments like %11/14/2005%

thanks in advance!
 
Try:

Set leads = dbCDMi.OpenRecordset _
("SELECT comments from leads_cdmi where comments like ""%" &
temp_search_date
& "%""", dbOpenForwardOnly)
 
THANK YOU! THANK YOU! THANK YOU!

Van T. Dinh said:
Try:

Set leads = dbCDMi.OpenRecordset _
("SELECT comments from leads_cdmi where comments like ""%" &
temp_search_date
& "%""", dbOpenForwardOnly)
 
I need to search a memo field and find all records with a specific date
somewhere in the comments...search_date below is defined as a "date"

Dim temp_search_date As String
temp_search_date = search_date
Set leads = dbCDMi.OpenRecordset _
("SELECT comments from leads_cdmi where comments like %" & temp_search_date
& "%", dbOpenForwardOnly)

why doesn't this work? I get an error message saying

3075
Syntax error in query expression 'comments like %11/14/2005%

thanks in advance!

The wildcard character in JET databases is * rather than %; and you
need quotemarks around the string you're searching for:

"SELECT comments from leads_cdmi where comments like '*" &
temp_search_date & "*'", dbOpenForwardOnly

so it will parse to

comments like '*11/14/2005*'

Note that if you have variably formatted dates in your memo field
(e.g. sometimes 8/10/2005 and sometimes 08/10/2005) you may miss data.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Counting Comments 1
SQL Not Working 5
Error 3075 When Appending Form Data to Table 2
run-time error '3075' 2
Execute SQL 1
SQL Server Express: Small Work Group Sans Server? 23
Run time error 2
Syntax problem 6

Back
Top