Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2010
    Posts
    12

    Unanswered: DoCmd.OpenQuery with Parameters?

    I have a form, ClientLookupFrm which has combo box ClientLookupCmb on it. I would like to select a value on the client lookup combo box and have it run the ClientItemQry with parameters. The parameter is that the bound column on the combo box goes to one of the values on the query, ClientAutoID. I have updated the afterupdate value to read:

    Private Sub ClientLookupCmb_AfterUpdate()

    DoCmd.OpenQuery ("ClientItemQry", , ,)
    WHERE "ClientAutoID = " & Me.ClientLookupCmb


    End Sub

    But this is not working. I clearly don't know VBA and am just fumbling through here, so please help! I have put the criteria
    [Forms]![ClientLookupFrm]![ClientLookupCmb]
    on the query (which runs well if I put the actual value in as a criteria instead of the code).

    Thank you!

  2. #2
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Assuming that your query is correctly requesting a parameter, you can do the following code in the AfterUpdate event (if you're using DAO):
    Code:
        With CurrentDb.QueryDefs("ClientItemQry")
            .Parameters("ParameterTextHere") = Me.ClientLookupCmb.Value
            .Execute
        End With
    Sam

  3. #3
    Join Date
    Aug 2010
    Posts
    12
    thanks so much!

Posting Permissions

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