Results 1 to 6 of 6
  1. #1
    Glenn_Suggs is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    72

    Error 3061. Too few parameters. Expected 1.

    This error keeps popping up from time to time and for the life of me I can't see where it's coming from. I have parameters passed to the SQL in the form of string variables so I don't see the problem. Any help with this would be greatly appreciated. It seems a simple enough SQL statement. Just returning a record from which I want to use the fields' values. Thanks in advance.



    Code:
    strWorkOrderKey = "123456V"
    strNetwork = "BUT50"
    strLocNum = "84-26"
    strLocationID = "1234567890123456"
    
    strSQL = "select * from wo1 w, wov001 wv " & _
                             "where w.wo1_key = wv.wo1_ptr " & _
                            "and w.wo1_key = '" & strWorkOrderKey & "' " & _
                            "and w.code = '" & strNetwork & "' " & _
                            "and w.location = '" & strLocNum & "' " & _
                            "and w.locationid = '" & strLocationID & "'"
    set rsWO = CurrentDB.OopenRecordset(strSQL, dbOpenSnapshot)

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Need to see your table layouts/fields.
    But , there is an error here
    CurrentDB.OopenRecordset(strSQL, dbOpenSnapshot)

    3061 can often be from a spelling mistakes.

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    It is more likely that the spelling mistake is in a reference to one of the fields in Wol or wov001; that is the first place I look when I get that error.

    e.g. should locationid be location_ID?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    On top of those thoughts, is it really is intermittent (as implied by "from time to time")? If so, I'd suspect a data issue rather than a spelling mistake. Could any of the variable values have an apostrophe or quotes in them? They appear hard-coded here, but I assume in real life they aren't.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Maybe:

    strSQL = "select * from wo1 AS w, wov001 AS wv " & _

    But since you say the statement usually works, this is probably not relevant.

    If values have ' or " in the string, such as O'Hare or 18", going to be an issue in the compiled statement as noted by Paul. Need to double the character. The apostrophe is easy to handle with Replace() function but this is why I try to prevent data with quote marks.

    However, judging by the fieldnames and example values, this does not appear to be type of data to contain ' or " punctuation but not impossible.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    In my experience the "AS" is optional. Works without for me in Access and SQL Server.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Runtime Error 3061. Too few parameters, expected 2
    By Gina Maylone in forum Programming
    Replies: 35
    Last Post: 01-13-2014, 02:37 PM
  2. Replies: 3
    Last Post: 04-26-2013, 01:37 PM
  3. Runtime Error 3061 Expected 3
    By kumail123 in forum Programming
    Replies: 1
    Last Post: 03-28-2012, 09:44 AM
  4. 3061 Error. Too few parameters. Expected 1.
    By rghollenbeck in forum Queries
    Replies: 5
    Last Post: 09-28-2011, 12:12 PM
  5. Replies: 1
    Last Post: 05-21-2011, 01:33 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