How do i link a control button to a combo box filter?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fairy56
    New Member
    • Feb 2010
    • 11

    How do i link a control button to a combo box filter?

    How can i link a control button to view a report based on the information selected in a combo box?

    For example
    I want to show all records for people with the name Steve.
    I can select Steve from the combo box then i want to be able to press a preview button to view the filtered report for all records with the name Steve.

    I dont like to use VBA so if anyone can explain using the macro builder that would be great!
  • NDayave
    New Member
    • Feb 2007
    • 92

    #2
    Hi,

    If you want to do this without VBA, follow these steps:

    1) Name your combo box Eg. "cboName"
    2) Make a query in design view selecting the fields you want from the table with the names stored
    3) In the Name Criteria field, write "[Forms]![YourFormName].[cboName]"
    4) Make a report with the Wizard based on the Query you just made
    5) On the form, make a button and in the wizard select Report Operations -> Preview Report and select the report that you have just made.
    6) Give the button a suitable name as well Eg. "cmdPreview "

    That should do what you want to do,

    NDayave

    Comment

    • fairy56
      New Member
      • Feb 2010
      • 11

      #3
      Sorry i'm new to this!

      Point 3 - In the Name Criteria field, write "[Forms]![YourFormName].[cboName]"

      which section does this relate to? The combo box/ query?

      Thank you for your help so far!

      Comment

      • NDayave
        New Member
        • Feb 2007
        • 92

        #4
        When you have made your query, open it in design view. Where you have your Name field selected, should look something like

        Field: Name
        Table: YourTableName
        Sort:
        Show: Ticked
        Criteria: <This is where you put [Forms]![YourFormName].[cboName]>

        You need to substitute YourFormName for the name of the form that the combo box is on, and cboName for the name of the combo box.


        What this does, is when your form is open and there is a selection in the combo box, it will take the selection and enter it into the query, only selecting the records from the table that match it.
        If you want to test if it is working, open the form, select something in your combo box, then run the query and see if the results match the selection you have made in the combo box.

        Comment

        • fairy56
          New Member
          • Feb 2010
          • 11

          #5
          Hi
          Sorry i thought i'd cracked this but then the following error msg came up

          'The Expression On Click you entered as the event property setting produced the following error: Ambiguous name detected: CorrectivePrevi ew_Click.'

          CorrectivePrevi ew is the name of the button.

          The query works on its own, and the combo is picking the results i need from the right table, i just cant get them to work together.

          Any ideas?

          Thanks!

          Comment

          • NDayave
            New Member
            • Feb 2007
            • 92

            #6
            It looks like you have called your command button "CorrectivePrev iew_Click" somewhere. Are you sure you have entered "[Forms]![YourFormName].[CorrectivePrevi ew]" exactly into the criteria section of the query?

            If you have, open your form in design view, press ALT+F11 and paste everything you can see in the code window here so I can have a look at it.

            Comment

            • fairy56
              New Member
              • Feb 2010
              • 11

              #7
              Hi

              It's ok - I deleted all VB coding relating to the form and then re-did the button.

              its works great now!! Thankyou for all your help!. Im sure i will come across another query again soon.

              Many thanks!

              Comment

              • NDayave
                New Member
                • Feb 2007
                • 92

                #8
                No problem, we all got to start out somewhere.

                Glad you got it sorted :)

                Comment

                • fairy56
                  New Member
                  • Feb 2010
                  • 11

                  #9
                  Hi

                  Sorry another quick query.

                  I have built a report with a header in 'Report Header'. However although this shows in print preview it will only print when i print on high quality, if i try printing a fast draft it doesnt appear... is there anything i can do for this?

                  Thanks

                  Comment

                  • NDayave
                    New Member
                    • Feb 2007
                    • 92

                    #10
                    Personally I can't think of why it would be doing that, perhaps it is an issue with your printer?

                    Try Printing something in fast draft with text in the same place on the page as the report header to see if it is being cut off as part of the 'Fast Draft' page setup.

                    As for anything else, I am at a loss.

                    Comment

                    • fairy56
                      New Member
                      • Feb 2010
                      • 11

                      #11
                      It's ok - my colleague has the same problem, and the same printer so it must be something to do with that!

                      Thanks for all your help! im sure i will be asking again soon, probably monday lol!

                      Comment

                      Working...