Results 1 to 2 of 2

Thread: Parameter Query

  1. #1
    Join Date
    Mar 2002
    Posts
    192

    Unanswered: Parameter Query

    How does one pass a value to a parameter query in code?

    I looked into the DoCmd.OpenQuery and RunQuery and nothing seems to stand out.

  2. #2
    Join Date
    Dec 2002
    Posts
    1

    Smile Re: Parameter Query

    Originally posted by access_dude
    How does one pass a value to a parameter query in code?

    I looked into the DoCmd.OpenQuery and RunQuery and nothing seems to stand out.

    1)First you must define parameters in your query design. From the menu, select Query | Parameters...

    2)Then in your code
    Dim qy as DAO.QueryDef
    Dim rs as DAO.Recordset

    Set qy = CurrentDB.QueryDefs("YourQueryName")
    qy("FirstParameter") = variable1
    qy("SecondParameter") = variable2
    ...

    ''''''' if query does not return results
    qy.execute
    '''''' if query returns results
    set rs = qy.OpenRecordset(dbOpenForwardOnly)
    ...

    rs.close
    set rs = nothing



    Hope this is the answer you are looking for. Good luck!

Posting Permissions

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