Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634

    Unanswered: openrecordset criteria problem

    I am trying to open a recordset using Set rstTurnoverBreakout = db.OpenRecordset("qryQDVL_TOBreakout") in the click event of a button on a form. qryQDVL_TOBreakout is based on a query that uses a combobox from the same form as criteria. I am getting the following error: Run-time error '3061': To few parameters. Expected 1.

    If I remove or hard code the criteria, the code runs fine. If I open the query, either directly of in code using docm.openquery, it works fine with the crieria.

    Any ideas as to why the parameter is not found when using OpenRecordset and/or possible solutions would be appreciated.

  2. #2
    Join Date
    Jan 2009
    Location
    Kerala, India
    Posts
    183

    openrecordset criteria problem

    Try executing the following statement just before the Recordset Open statement, in the button click event.

    Code:
    Me.Refresh
    Set rstTurnoverBreakout = db.OpenRecordset("qryQDVL_TOBreakout")
    The first statement will update the underlying Query with the changed Combobox value. I think you can work with the RecordsetClone of the Form as well, after the refresh statement.

    Code:
    Set rstTurnoverBreakout = Me.Recordsetclone
    www.MsAccessTips.com (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

  3. #3
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    What's the SQL statement of qryQDVL_TOBreakout?
    Have a nice day!

  4. #4
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    Thanks for the responses.


    I found the solution....
    Use Eval("[Forms]![FormName]![ControlName]") as criteria in the query.

  5. #5
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    As an FYI, this is the issue and has one fix:

    ACC2000: "Too Few Parameters. Expected 1" Error Message

    but as you've found another fix is the Eval() function.
    Paul

Posting Permissions

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