Results 1 to 3 of 3
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question SQL syntax

    I'm getting the "Too few parameters, expected 1" error. Can someone look at my SQL to make sure it's in proper order?



    Code:
    mySQL = "SELECT [WE Date] AS WeekEnd, Store, [Returns Recycles] AS Backhaul, [# of Cases] AS NumCases," & _
                "[Total Time to Unload] AS UnloadTime, [# of Team Members Unloading] AS NumUnloading," & _
                "[Cartons per Hour (CPH)] AS CPH FROM FINAL_OTM_ODS_UPLOAD WHERE [Store] = " & lngStore & " AND [WeekEnd] = #" & dtWeek & "#;"
    Thanks in advance.

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    why do you have an SQL variable set to a select statement? the only thing you can do with a select statement in vba is open up a recordset.

    other than that, I don't see any errors. Other than that access might not like the # signs? or () sings inside of field names?? is the 'AS' keyword allowed in vba?

    it's always a good idea never to have spaces in field names. replace them with _'s

  3. #3
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Yea, unfortunately the source table is not mine and I did not have control over the design. My intent is to use it in a recordset. I figured out the error and it kind of perplexes me. In my week criteria I had to use the actual field name, not the variable name.

    Code:
    mySQL = "SELECT [WE Date] AS WeekEnd, Store, [Returns Recycles] AS Backhaul, [# of Cases] AS NumCases," & _
    "[Total Time to Unload] AS UnloadTime, [# of Team Members Unloading] AS NumUnloading," & _
    "[Cartons per Hour (CPH)] AS CPH FROM FINAL_OTM_ODS_UPLOAD WHERE [Store] = " & lngStore & " AND [WE Date] = #" & dtWeek & "#;"
    Thanks for your help!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Simple Syntax Help
    By cvegas in forum Programming
    Replies: 7
    Last Post: 04-20-2011, 01:46 PM
  2. SQL syntax
    By dssrun in forum Queries
    Replies: 4
    Last Post: 04-15-2011, 01:06 PM
  3. Help with syntax
    By GWB in forum Queries
    Replies: 4
    Last Post: 01-26-2011, 03:33 PM
  4. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  5. Please help SQL Syntax
    By jordanturner in forum Access
    Replies: 4
    Last Post: 09-02-2010, 08:05 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums