Problems with my Query

Results 1 to 6 of 6

Thread: Problems with my Query

  1. #1
    Tom Anderson Guest

    Default Problems with my Query

    Can anyone please look at this and tell me where my problem is. I can not seem to be able to find the answer. I am using Access 2000 on win 2000 prof. I get this error:<BR>Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)<BR>[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.<BR><BR>The error is comming from my WHERE clause (When I remove it I get no error), I have replaced the variable mvar with now() in the WHERE caluse and it works just fine, messages.Date is a date field. Is there something I&#039m missing with the date translation? Any help would be most appreciated.<BR><BR>mvar = formatDateTime("10/19/2000 12:00:01 PM")<BR>myDSN = "msgbrd"<BR>mySQL = "SELECT messages.ThreadID" &#039 Numeric field<BR>mySQL = mySQL & ", threads.ThreadHeader" &#039Text Field<BR>mySQL = mySQL & ", threads.numPosts"<BR>mySQL = mySQL & ", count(*) as NewRecs"<BR>mySQL = mySQL & " FROM messages LEFT JOIN threads ON messages.ThreadID = threads.ThreadID"<BR>mySQL = mySQL & " WHERE messages.Date &#060; mvar"<BR>mySQL = mySQL & " GROUP by Messages.ThreadID, threads.ThreadHeader, threads.numPosts"

  2. #2
    Tom Anderson Guest

    Default Never Mind I have no brain

    For those of you who may be wondering. I had it setup like this.<BR><BR>mySQL = mySQL & " WHERE &#060; mvar"<BR><BR>instead of:<BR><BR>mySQL = mySQL & " WHERE &#060; " & mvar<BR><BR>I feel dumb

  3. #3
    MG Guest

    Default RE: Problems with my Query

    First your variable is within the quotes so it will the messages.Date is getting compared to the string "mvar". It should be like this.<BR>mySQL = mySQL & " WHERE messages.Date &#060; " & mvar <BR><BR>Then, you need to surround dates with # in Access.<BR>mySQL = mySQL & " WHERE messages.Date &#060; #" & mvar & "#"<BR><BR>If this does not work, response.write the sql string and post it. Then we can see the error easier.<BR><BR>

  4. #4
    Join Date
    Dec 1969

    Default RE: Problems with my Query

    I think you need #&#039s around mvar since it is a date field:<BR><BR>mySQL=mySQL & "WHERE messages.Date &#060; #mvar#"

  5. #5
    Tom Anderson Guest

    Default RE: Problems with my Query

    Thanx for the response.

  6. #6
    Tom Anderson Guest

    Default Thnx for the reply


Posting Permissions

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