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

    Question

  • Help!

    I have the following 'set recordset' line that I cannot get working. The parameters seem correct according to all available help I can find on the subject...

    The error displays "Run-time error '3061'. Too few parameters. Expected 1."

    Here is the line of code:

    Set rs = dbs.OpenRecordset("SELECT Centre_X, Centre_Y FROM [qry_all_details] WHERE ID = " & siteID & ";", dbOpenSnapshot)

    Where rs is the recordset (Dim rs As Recordset) and dbs = CurrentDb()

    Any help would be appreciated.

    Many thanks..

    Thursday, March 24, 2011 4:33 PM

All replies

  • For what it is worth...

    My xl97 openRecordSet help file show 4 arguments: (source, type, options, lockedits) for a database object.
    The last three arguments are optional.
    Try adding two commas after dbOpenSnapshot.
    '---
    Jim Cone
    Portland, Oregon USA
    http://www.mediafire.com/PrimitiveSoftware
    (free and commercial excel programs)

    Thursday, March 24, 2011 6:45 PM
  • Jim,

    Thanks for your reply. I did try this, but it only causes a further error:

    "Compile error: Expected: expression"

    Thursday, March 24, 2011 7:00 PM
  • Hi,

    Try

    Set rs = dbs.OpenRecordset("SELECT Centre_X, Centre_Y FROM [qry_all_details] WHERE ID = '" & siteID & "'", dbOpenSnapshot)

    Notice I've added single quotes before and after the double quotes. If you still have problems, remove the WHERE clause. If no error returns, then there's a problem in the WHERE clause (I'd bet the WHERE is the problem).

    Rgds


    Tiago Cardoso VB / VBA Analyst
    Thursday, March 24, 2011 8:16 PM
  • Hi Tiago,

     

    I tried the single quotes as above - same error.

    I also tried taking out the WHERE clause - same error.

    Cheers

    Friday, March 25, 2011 8:28 AM