PDA

Click to See Complete Forum and Search --> : Access generated SQL ain't all it is to it


gvirden
Jan 3rd, 2000, 06:03 AM
For one thing if you don't have your little duckies in order, ie.,... ',",(,&,space, , ...after pasting that perfect code and here are a few I would like to add (!!###@@**!!) you'll get the dreaded syntax error blah. Well, when I think I finally have it figured out they hit me with the even worse "Data type mismatch in criteria expression".

VB adamantly rejects this-

Dim today As Date
today = Date
Set rs = g_DB.Execute("SELECT FeedBins.Bin, Sum(FeedBins.FeedIn) AS TotalIn, Sum(FeedBins.FeedOut) AS TotalOut, FeedBins.Date " & _
"From FeedBins " & _
"GROUP BY FeedBins.Bin, FeedBins.Date " & _
"Having (((FeedBins.Date)='" & today & "')) " & _
"ORDER BY FeedBins.Bin DESC")

Why?

JHausmann
Jan 3rd, 2000, 07:27 AM
Date parameters need to be bracketed with #, in Access queries.

Try replacing

"Having (((FeedBins.Date)='" & today & "')) " & _

with
"Having (((FeedBins.Date)=#" & today & "#)) " & _

gvirden
Jan 3rd, 2000, 10:53 PM
This is my change.

"Having (((FeedBins.Date)=#'" & today & "'#)) " & _

This came back.
"Syntax error in date in query expression"

jpark
Jan 4th, 2000, 12:16 AM
Copy JHausmann's code and paste it, and try again.

Your changed code isn't exactly what JHausmann gave to you.

The single quote shouldn't be there.

Joon

gvirden
Jan 4th, 2000, 01:12 AM
You are absolutely right.

I'll go get my eyes checked today.