vb sql headache - required parameter missing

alcifer_c

Registered User.
Local time
Today, 06:41
Joined
Jun 3, 2002
Messages
42
Any idea what parameter would be missing?
I created the query using the QBE grid. When the string is compiled, it looks identical to the sql view of the QBE query that I created.

I would like to see all of the "calls" logged yesterday before 12:00.

If I take out the part with the time, the query runs okay...need to put time parameters though.

Code:
strSQl = "SELECT [call counter].logdate, Format([logtime]," & "hh" & ") AS expr1, Count([call counter].callCount) AS CountOfcallCount FROM [call counter] GROUP BY [call counter].logdate, Format([logtime]," & "hh" & ") HAVING ((([call counter].logdate) = #1/29/2006#) And ((format([logtime]," & "hh" & ")) < 12))"

Thanks,

Al
 
alcifer_c said:
When the string is compiled, it looks identical to the sql view of the QBE query that I created.

I suspect it is not quite identical.

Try this little exercise to see where you've gone wrong.

1) Copy the code after strSQL= into your clipboard
2) go into debug window and enter a question mark then paste in the bit you copied, and press enter
3) The result (of the "compiled" sql string) will appear in the debug window in the line below.

Note how there are no double quotes around the hh in the result.

Format([logtime],hh) AS expr1

Pat hartman shows a technique in this post that you can use to solve your problem. Alternately you can hard code in the extra quotes, but Pat's technique can help to avoid the confusion that so many double quotes often causes.

HTH

Regards

John
 
is [call counter] a query or a table? if it is a query that has parameters in it you will need to pass them to the VBA

Peter
 

Users who are viewing this thread

Back
Top Bottom