sql in vba line of code error

ECEstudent

Registered User.
Local time
Today, 10:07
Joined
Jun 12, 2013
Messages
153
SQL line of code error

:(Does anyone know what's wrong with this line of code? It keeps giving me a syntax error...

Set rst = CurrentDb.OpenRecordset( _
"Select * from CalculateTotal WHERE ((Structure) Like'*" & u & "*'")AND (((ShipDate) BETWEEN #09/30/2001# AND #10/01/2012#)) ")
 
Does anyone know what's wrong with this line of code? It keeps giving me a syntax error...

Set rst = CurrentDb.OpenRecordset( _
"Select * from CalculateTotal WHERE ((Structure) Like'*" & u & "*'")AND (((ShipDate) BETWEEN #09/30/2001# AND #10/01/2012#)) ")
 
Looks like you need a space after the paren just before the word AND
 
Re: SQL line of code error

Try:
Code:
Set rst = CurrentDb.OpenRecordset( _
"SELECT * FROM CalculateTotal WHERE (((Structure) Like ""*"" & '" & u & "' & ""*"") AND ((ShipDate) BETWEEN #09/30/2001# AND #10/01/2012#));"

I changed your Like statement and added an opening parenthesis after WHERE.
 
Ok. Thanks. Figured it out! :D

Supposed to look like this:

Set rst = CurrentDb.OpenRecordset( _
"Select * from CalculateTotal WHERE ((Structure) Like'*" & u & "*')AND (((ShipDate) BETWEEN #09/30/2001# AND #10/01/2012#)) ")
 
I merged your duplicate threads since they both had responses. In the future, please don't post the same question twice.
 

Users who are viewing this thread

Back
Top Bottom