I have a search form that has a bunch of unbound comboboxes from which the user selects values and then clicks a search button that builds an SQL string based on the values entered. The results are then assigned to the ControlSource of a subform. The user can execute as many different searches as they like and the results in the subform update on the fly.
The form is also intended to allow the user to be able to preview (and print if desired) a report of the current selection by clicking a PreviewReport button.
Problem is I don't know how to set the report's RecordSource and allow it to change on the fly.
As far as I know, I can't set the RecordSource of the report before the report is opened. Instead, I have to use the report's OnOpen event but how can I set the report's RecordSource in OnOpen to an SQL string in a module in the form?
If I use CreateQueryDef and set the RecordSource (not in OnOpen) to the new query name, if I then change the selection in the form to return a different set of records and then try to go to the report, I get the error message that the query object already exists.
Does anyone have any suggestions on how to make the report change it's set of records according to the selection made in the form?
Any advice is greatly appreciated. lastout (the game's not over till it's over)
The form is also intended to allow the user to be able to preview (and print if desired) a report of the current selection by clicking a PreviewReport button.
Problem is I don't know how to set the report's RecordSource and allow it to change on the fly.
As far as I know, I can't set the RecordSource of the report before the report is opened. Instead, I have to use the report's OnOpen event but how can I set the report's RecordSource in OnOpen to an SQL string in a module in the form?
If I use CreateQueryDef and set the RecordSource (not in OnOpen) to the new query name, if I then change the selection in the form to return a different set of records and then try to go to the report, I get the error message that the query object already exists.
Does anyone have any suggestions on how to make the report change it's set of records according to the selection made in the form?
Any advice is greatly appreciated. lastout (the game's not over till it's over)