Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Nov 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using a combo box to specify a critieria in query (Access 2000)

    Hi guys!
    Can anyone tell me the correct syntax for specifying a criteria in a query using the values in a combo box on an unbound form?
    here are the info:
    Form name: frmUnit
    Combobox name on the form: cboUnitList

    Basically, the query has a field called Unit. In the criteria of the Unit column, I have type the following syntax:

    Like "*Forms![frmUnit]![cboUnitList]*"

    I wanted to do this so that the query will take the value in the combo box and then use it as criteria to select any person whose Unit field contains the value specified by the combo box.

    Do I have the right syntax? Cause everytime I run the query from frmUnit (after specifying the combobox value), the query comes up blank. and I know its supposed to select a few records.

    thanks you guys!
    quiddy

  2. #2
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using a combo box to specify a critieria in query (Access 2000)

    I think it should be more like this:

    Forms![frmUnit]![cboUnitList]

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Using a combo box to specify a critieria in query (Access 2000)

    For the like to work it needs to be:

    Like "*" & Forms![frmUnit]![cboUnitList] & "*"
    Regards
    John



  4. #4
    New Lounger
    Join Date
    Nov 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using a combo box to specify a critieria in query (Access 2000)

    Thanks, but isn't that what I have ? Do you mean taking out the asterisks (*) and the quotations and "Like"? I tried urs but it still does not work. Do you think it may have to do with the form closing when I run the query? I don't think that is the case cause the form stays open. I simply have a command button on the form that I made from a wizard that runs the query. But when I specify a value in the combo box and click on the run query button, the query opens up with no results.
    thanks!
    chris

  5. #5
    New Lounger
    Join Date
    Nov 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using a combo box to specify a critieria in query (Access 2000)

    yay!! it worked! omg thanks so much. i guess i was missing those stupid ampersands and the quotations marks around the asterisks. thanks so much!!!

  6. #6
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using a combo box to specify a critieria in query (Access 2000)

    Sorry I didn't <img src=/S/rtfm.gif border=0 alt=rtfm width=24 height=23>

Posting Permissions

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