By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,456 Members | 1,952 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,456 IT Pros & Developers. It's quick & easy.

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

P: 11
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!
Feb 16 '10 #1
Share this Question
Share on Google+
10 Replies


P: 92
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
Feb 16 '10 #2

P: 11
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!
Feb 16 '10 #3

P: 92
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.
Feb 16 '10 #4

P: 11
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: CorrectivePreview_Click.'

CorrectivePreview 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!
Feb 17 '10 #5

P: 92
It looks like you have called your command button "CorrectivePreview_Click" somewhere. Are you sure you have entered "[Forms]![YourFormName].[CorrectivePreview]" 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.
Feb 17 '10 #6

P: 11
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!
Feb 18 '10 #7

P: 92
No problem, we all got to start out somewhere.

Glad you got it sorted :)
Feb 18 '10 #8

P: 11
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
Feb 19 '10 #9

P: 92
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.
Feb 19 '10 #10

P: 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!
Feb 19 '10 #11

Post your reply

Sign in to post your reply or Sign up for a free account.