Results 1 to 5 of 5

Thread: Access generated SQL ain't all it is to it

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 1999
    Location
    Greenville, MS, Washington
    Posts
    38

    Post

    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?

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    Date parameters need to be bracketed with #, in Access queries.

    Try replacing

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

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

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 1999
    Location
    Greenville, MS, Washington
    Posts
    38

    Post

    This is my change.

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

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

  4. #4
    Member
    Join Date
    Jan 1999
    Location
    Garden Grove, CA, Orange
    Posts
    55

    Post

    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

  5. #5

    Thread Starter
    Member
    Join Date
    Dec 1999
    Location
    Greenville, MS, Washington
    Posts
    38

    Post

    You are absolutely right.

    I'll go get my eyes checked today.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width