Hello folks -
My question is twofold.
- I have around twenty assorted tables in a database. The table layouts are diverse; the one common thread is that all of them have a 'County' field.
I need to set up a series of reports which allow a user to select a county from a drop-down box, triggering the report to run and return only records attached to that particular county.
This is doable at the datasheet level using a filter-by-form, but that's pretty clunky and I have several tables/queries which will need this same county filter.
I may be halfway there with the following:
Create an unbound form. Add a combo box. Set the Row Source of the combo box to include the County field. Set its Bound column to 1. Set its Column Count property to 2. Set the Column Width property to 0";1" Name the Combo Box 'ChooseCounty'.
Add a Command Button to the form. Code the button's click event as follows:
(Note: To write the code, in Form Design View select the command button. Display the button's property sheet. Click on the Event tab. On the On Click line, write:
[Event Procedure]
Click on the little button with the 3 dots that appears on that line. When the code window opens, the cursor will be flashing between two already existing lines of code. Between those lines, write the following code.)
Me.Visible = False
Close the Code window.
Name this form 'ChooseCounty'.
In the Query that is the Report's Record Source [County] field criteria line, write:
forms!ChooseCounty!ChooseCounty
Next, code the Report's Open event: (Using the same method as described above)
DoCmd.OpenForm "ChooseCounty", , , , , acDialog
Code the report's Close event:
DoCmd.Close acForm, "ChooseCounty"
When ready to run the report, open the report. The form will open and wait for the selection of the Company. Click the command button and then report will run. When the report closes, it will close the form.
I can persuade the report to trigger the form, but only once - I can't seem to figure out where precisely the 'forms!ChooseCounty!ChooseCounty' needs to go. Perhaps someone can clarify or offer a more elegant way to do this?
- I need to set up a large meta-report containing sub-reports on all of the tables - and, using the same drop-down 'choose a county' form, I need to have that choice cascade down through all the subreports. I don't have the faintest idea how to go about this. Suggestions welcome!
~ T