Results 1 to 4 of 4
  1. #1
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291

    Why am I getting error: too few parameters?

    I am trying to open a recordset through a variable passed in like this:
    Function fConcatChild2(rsDI As Integer) As String
    .....
    Set rs = db.OpenRecordset("Select [PACP Defect] From [Inspections Detail] Where [ID] = rsDI", dbOpenSnapshot)

    I am getting an error:


    Run-time error '3061':
    Too few parameters. Expected 1.

    Then I replace rsDI with the number 32 and it works, what is the difference? I have set a watch and breakpoint before this and rsDI does = 32 when I get the error.

    Working example:
    Set rs = db.OpenRecordset("Select [PACP Defect] From [Inspections Detail] Where [ID] = 32", dbOpenSnapshot)

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You have to concatenate the variable:

    Set rs = db.OpenRecordset("Select [PACP Defect] From [Inspections Detail] Where [ID] = " & rsDI, dbOpenSnapshot)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291
    NICE, *high five* pbaldy

  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
    LOL! Glad it helped.
    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. Report parameters
    By saylindara in forum Reports
    Replies: 15
    Last Post: 08-02-2009, 03:49 PM
  2. Parameters of all fields
    By seen123 in forum Import/Export Data
    Replies: 1
    Last Post: 02-20-2009, 02:50 PM
  3. Too few parameters. Expected 2.
    By PPCMIS2009 in forum Access
    Replies: 0
    Last Post: 01-28-2009, 01:02 PM
  4. Replies: 0
    Last Post: 02-15-2007, 03:07 PM
  5. Input parameters
    By GloriaLuz in forum Reports
    Replies: 0
    Last Post: 11-14-2005, 09:38 PM

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