Results 1 to 8 of 8
  1. #1
    lefty2cox is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    May 2013
    Posts
    163

    Run-Time Error 3061

    I have this function that keeps returning a run time error.



    Error: "Run-Time Error '3061' Too few parameters. Expected 5"

    The query referenced has 6 fields, 5 of which contain criteria. The current status of the query has records and is not null. The error throws on the "set rs" line. As you can see, I haven't given any instruction to the function as of yet. Not sure if that matters.

    Code:
    Function lastHitDate()
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strSQL As String
    strSQL = "SELECT * FROM qryclumpmatch"
    Set db = CurrentDb
    Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
    End Function
    Thanks
    Lefty

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

  3. #3
    lefty2cox is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    May 2013
    Posts
    163
    Quote Originally Posted by orange View Post
    Can you post a copy of the database?
    Not quite sure how to do that

  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,518
    More than likely the query has 5 form references in it. Easiest workaround is using the Eval() function around each.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Instructions for attaching a database (from June7's signature)

    To provide db: Make copy, remove confidential data, run compact & repair, zip w/Windows Compression if over 500KB (2MB zip allowed), attach to post. Attachment Manager is below the Advanced post editor window, click Go Advanced below the Quick Reply window.

  6. #6
    lefty2cox is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    May 2013
    Posts
    163
    Quote Originally Posted by pbaldy View Post
    More than likely the query has 5 form references in it. Easiest workaround is using the Eval() function around each.
    This is true. The query has 5 form references as criteria for the fields in the query. I took an alternate route and wrote code to examine the underlying table that the query was pulling from. The only difference seems to be it takes a few seconds because I'm examining many more records than the the query.

    That being said, I'm curious about the Eval function. So if I understand you correctly, because the query is filtering based on form references, I need to use the eval function? So if the field in the query is say "field1" then I need to refer to it as "Eval(field1)" in the code?

    The weird part is that I've referred to the same query with the same code in other subs and didn't have a problem. Is there a difference when I use it in a sub vs a function?

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No difference sub or function. Copy the code that worked elsewhere. I'll be surprised if you opened a recordset on it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    lefty2cox is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    May 2013
    Posts
    163
    Quote Originally Posted by pbaldy View Post
    No difference sub or function. Copy the code that worked elsewhere. I'll be surprised if you opened a recordset on it.

    You are correct. I reviewed my code. This was the first time I went at this particular query with code. To correct my prior post, I ultimately wrote code for a query that was based on a table, not the table itself. This query has no form references and serves the purpose just fine. It all makes sense now. Thanks for the help.

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

Similar Threads

  1. Run Time error 3061
    By sdel_nevo in forum Programming
    Replies: 6
    Last Post: 06-08-2015, 10:09 AM
  2. Run time error 3061
    By beaurou in forum Modules
    Replies: 18
    Last Post: 02-23-2015, 11:54 AM
  3. Run-Time Error 3061
    By GraeagleBill in forum Programming
    Replies: 2
    Last Post: 09-23-2013, 06:46 AM
  4. Run-time error 3061
    By boywonder in forum Programming
    Replies: 1
    Last Post: 07-20-2011, 06:14 AM
  5. Run-Time error 3061
    By boywonder in forum Programming
    Replies: 12
    Last Post: 05-24-2011, 10:15 AM

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