• Combo Box as parameters for a query (2003 All Updates)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Combo Box as parameters for a query (2003 All Updates)

    Author
    Topic
    #442705

    Is there any easy way to use the equivalent of a combo box to filter a query ie when you run the query , have combo box appear with a list of allowable paramaters (eg States or countries) and have the ability to select all of them, just one or a number of them to feed the query
    TIA
    Steve

    Viewing 1 reply thread
    Author
    Replies
    • #1066263

      Use a combo box on a form, and set the criteria to something like

      [Forms]![NameOfForm]![NameOfComboBox]

      The form should be open before the query is used. The form won’t be opened automatically if the query is run from the database window, but since end users should never run something from the database window, that shouldn’t be a problem.

      • #1066275

        Sorry Hans – totally lost -put the criteria where
        Steve

        • #1066277

          In the design of the query, in the Criteria line of the column you want to filter on.

          • #1066417

            Following on from help by Hans and John, I attach a cut down version of the database.
            Two major tables: STKB which holds data relating to Stock and DAVEID which holds the list of GROUPS.
            The ChooseGroupsForm is designed to allow you to choose one, several or All Groups. This process is working fine (after much confusion on my part !!). However I want to apply the results of this query to the query qryProductProfitabilitySearch and have no idea how to do this.
            Any help appreciated
            TIA
            Steve

            • #1066419

              You have an organizational (or design) problem that you’ll have to solve before continuing. The IDCODEs in the DAVEID table do not correspond to the IDCODEs in the STKB table. For example, DAVEID contains the IDCODE “WINE”, containing descriptions such as “WINES”, “WINES RED”, “WINES WHITE” etc. However, the records in STKB that are about wines contain IDCODEs such as REDS, WHIT and SWIN. Because of this inconsistency, you cannot join the tables on the IDCODE field. You will have to tackle this first. You’ll have to decide for yourself in which table you’re going to change the codes to match those in the other one. And perhaps you should use the CODENO field from DAVEID, but I don’t see an equivalent field in STKB at first sight.

            • #1066430

              Hans
              Stupid of me that I didnt check.(not my database by the way)
              I think I’m there now – thnks to John and yourself for your help
              Steve

            • #1066432

              I see that you edited your reply. For what it’s worth, I have attached the version I created in reaction to the question in the original version.

            • #1066566

              Hans
              Thank you – the query is now working well. I had to change the source from the Table STKB to a query as there are calculated fields required in the report and I noticed that it would only read the first 4 letters of the query name (presumably because the original table source was 4 letters long). I just changed the name of the query to be 4 letters long
              However, because of my inexperience, I have had to make production of the associated report a 2 step process (2 buttons on the form)
              Button 1 calls up the query after selections are made
              Button 2 opens the report based on this query
              It works but its not pretty. Is there anyway to open the report in preview mode as soon as the groups are selected and the “run query” button clicked
              Steve

            • #1066567

              You don’t have to alter a query before opening the report. you can pass the where-condition to the report. See the attached version. The report is nothing special, just a slightly modified autoreport; it is only meant as an illustration that you can use one query and one report to display different selections.

    • #1066272

      [indent]


      just one or a number of them to feed the query


      [/indent]

      Combo Boxes do not allow multiple selection. To allow more than one you need a list box with the multi select property set to either Simple or Extended

    Viewing 1 reply thread
    Reply To: Combo Box as parameters for a query (2003 All Updates)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: