Results 1 to 2 of 2
  1. #1
    nightowl128 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2017
    Posts
    7

    Passing parameters to union query

    I have 2 select queries and 1 append union query that uses the 2 select queries. The select queries use [TempVars] in the where clause. Im trying to call the append query from vba, DoCmd.Execute qryName, but I get a Run-time error 3061 - Too few parameters. Expected 3.

    I've searched and tried several things to set the parameters before calling the append query but still get the error. The append query does not use any [TempVars]'s.

    Try 1:
    For Each p In qd.Parameters


    p.Value = Eval(p.Name)
    Next

    Try 2:
    Set qd = db.QueryDefs("qryManagerRanking100")
    qd.Parameters("[TempVars]![FacLevel]").Value = [TempVars]![FacLevel]

    docmd.execute "qryManagerRanking100"

    How do I pass variables to a query that is being called from the query I execute?

  2. #2
    nightowl128 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2017
    Posts
    7
    I have found the answer. I was calling the append query incorrectly.
    The line:
    docmd.execute "qryManagerRanking100"
    should be:
    qd.execute

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

Similar Threads

  1. Passing parameters
    By reburton in forum Programming
    Replies: 3
    Last Post: 10-31-2013, 01:35 PM
  2. passing parameters to a query
    By PatrickCairns in forum Programming
    Replies: 1
    Last Post: 12-11-2012, 08:47 PM
  3. Passing parameters into vb using access query
    By markyboy171 in forum Programming
    Replies: 4
    Last Post: 06-15-2012, 05:46 AM
  4. Replies: 37
    Last Post: 09-15-2011, 11:57 AM
  5. Passing parameters to a query
    By stephenaa5 in forum Queries
    Replies: 3
    Last Post: 09-10-2010, 05:32 PM

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