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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Query 1

Status
Not open for further replies.

Gatorajc

MIS
Mar 1, 2002
423
US
I feel like I have posted a million of these things. But Im learning I guess that what counts, anyway.

Here is my problem. The last line of my query. I am trying to insert a variable, that comes from a form, which I have done a million times but now I need the correct syntax for putting it with a date.

sqlString = "SELECT Count(distinct Date) as total"
sqlString = sqlString & " From ProjectNotes"
sqlString = sqlString & " WHERE Date >= _
'&quot; & dte & &quot;''/1/02' And Date <= &quot; & dte & &quot;''/31/02'&quot;

With this all I get is an error incorrect syntax. I have tried different ways also

No ':
'&quot; & dte & &quot;'/1/02 And Date <= &quot; & dte & &quot;'/27/02&quot;

Produces this error:
Unclosed quotation mark before the character string '/27/02'

' around the whole date:
''&quot; & dte & &quot;'/1/02' And Date <= '&quot; & dte & &quot;'/31/02'&quot;

Produces this error:
Incorrect syntax near '4'.
Which is the number being passed in.

Thanks in advance for any help or nudges in the right direction.[lightsaber]
 
try:

sqlString = sqlString & &quot; WHERE Date >= _
'&quot; & dte & &quot;/1/02' And Date <= '&quot; & dte & &quot;/31/02'&quot;

if that doesnt work then remove the single quotes from the above statement
 
Thanks that worked great. I actually had already created the string before and then inserted it into the query but that is not the way I wanted it the less code the better but you cleared it up for me. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top