Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2007
    Posts
    3

    Unanswered: Help passing a parameter to a query

    I have a form with a combo box that when I select a value I want the hidden value (UserID) passed to a query that would open up a form that is set up like a data sheet. When I try to set up a form that would display the records related to the UserID I end up getting all records and the UserID column replaced with the passed value when I set the control source to = Forms!frmEmployeeInstances!cboShiftEmployees.Colum n(0)
    I don’t know if I can pass the value to a query (if the query can even acknowledge the passed value), so any help would be greatly appreciated.
    I have the OnClick set to open a form called frmShowInstances via a Macro but I could never get the Where Condition to work either.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    there are a dozen different ways to do this.
    here is the no-brain-required approach:

    design view the query that feeds your data sheet
    click design grid in the criteria box for the field concerned
    click the magic wand in the toolbar
    on the left of the three-window-window that opened, navigate: forms; all forms; the form holding your combo
    in the middle of the three-window-window, double-click the name of your combo

    your query now uses the combo selection as criteria ASSUMING that the combo has UserID as the bound column (fix it if necessary).

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Oct 2007
    Posts
    3
    Quote Originally Posted by izyrider
    there are a dozen different ways to do this.
    here is the no-brain-required approach:

    design view the query that feeds your data sheet
    click design grid in the criteria box for the field concerned
    click the magic wand in the toolbar
    on the left of the three-window-window that opened, navigate: forms; all forms; the form holding your combo
    in the middle of the three-window-window, double-click the name of your combo

    your query now uses the combo selection as criteria ASSUMING that the combo has UserID as the bound column (fix it if necessary).

    izy
    I have tried that but i can't get it to work. I can get it to where i can get a prompt and when i put in the userId i get what i am looking for. Would it be possible to code the OnClick event on the form that has the combo box to run a query and pass the UserID into that?

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    !! what prompt?
    there shouldn't be a prompt!

    what does the SQL of your query look like: it should be something like:

    SELECT someID, someText, someNum
    FROM tblSome
    WHERE someID=forms!frmWithTheCombo!myCombo

    NB - the form with the combo needs to be open when the query runs (i.e. when the other form opens)

    izy
    currently using SS 2008R2

Posting Permissions

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