Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    nittany77 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    15

    Combo box in query criteria

    I know this has been asked many times, I have searched those threads but can't seem to get this to work. I created a form with a combo box that nothing in control source, and another table in row source. In the query criteria I have [Forms]![Form1]![Combo0]. When I run the query I only get a text box where I can type in the data, the list does not pop up.

    Any idea what I am doing wrong?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Is Form1 open, with a selection made in Combo0 when you run the query
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    nittany77 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    15
    No it is not. I just tried it with the form open and a selection made and the data is filled in correctly in the query, but I still didn't get a selection box
    .

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    That will be the reason that a dialog box opens, requesting the data for the criteria. If you open the form and make a selection from the combo before running the query, all should be good.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    nittany77 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    15
    But I want the selection box to pop up when I run the query, I don't want to have to open the form first and do it there. Is this possible?

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by nittany77 View Post
    But I want the selection box to pop up when I run the query, I don't want to have to open the form first and do it there. Is this possible?
    So your problem is not that you have to enter data when the query runs, but when the data request is made, you want to display a combo box for the user to make a selection from. Is that correct?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    No, you can't put a combo box in a query and select from it there. You have to put the combo box on a form, make the selection there, and the run the query with the combo box VALUE in the criteria.

    John

  8. #8
    nittany77 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    15
    Yes that is correct. I don't want them to have to type it in.

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by nittany77 View Post
    Yes that is correct. I don't want them to have to type it in.
    IMHO users should only be allowed to open forms and reports. The data returned by a query should always be displayed in a form or report. So I would suggest a main form (unbound) with a subform in datasheet view which is bound to your query. Reference the combo on the main form in the criteria of the query. Instead of the user opening the query directly, they would open the main form. Let us know if you need a quick example of this.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  10. #10
    nittany77 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    15
    I think I understand what you are saying but an example would be great.

  11. #11
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    See if this helps:
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  12. #12
    nittany77 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    15
    I see how these two are tied together, but I don't see how I would use this in my case. I just tried a different way, I made a form where I can select all of the data and then put a button to run the appropriate query from this form. The only problem is that my data I select on the form is not making it into the query even though I have those form items listed in the criteria on the query. Sorry for being so dense....

  13. #13
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Can you post a copy of the db.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  14. #14
    nittany77 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    15
    See attached. What I would like to do is open the "query form", pick a start date, end date, and workcenter and get the appropriate data.
    Attached Files Attached Files

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Controls used for input of filter/search criteria must be UNBOUND, otherwise you change data in record.

    Unless you want to move the search controls and button to the Form Header and display records in the Detail section, there is no reason to bind this form to data.

    I never use dynamic parameterized queries. I use VBA code to build filter criteria and apply to the form or report when opened. Users do not work with tables and queries.

    For some reason the query still shows input popups for [Start Date] and [End Date]. The macro appears to have some parameters set up. Get rid of them I guess. I don't use macros and don't understand these parameters. AhHa! Found them by clicking Parameters from the ribbon Design tab.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 08-02-2014, 02:24 PM
  2. Replies: 3
    Last Post: 07-11-2014, 08:24 AM
  3. Combo Box for Query CRITERIA?
    By TUPJK in forum Queries
    Replies: 5
    Last Post: 06-04-2014, 10:43 AM
  4. Combo Boxes Query Criteria help
    By noaccessguru in forum Queries
    Replies: 2
    Last Post: 04-30-2012, 08:09 PM
  5. Replies: 6
    Last Post: 06-29-2010, 09:56 PM

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