Unanswered: On click event to select record source??
I am wondering is instead of having 10 querys and 10 relevent reports built in Access, can I have a template Report which on a specific button on click event would say open template report and change record source to query 1, or query 2 etc, which ever was relevent, could someone tell me if this is possible and if so an idea of the VB code required?
I think I looked at this in the past but as soon as I started thinking about groupings etc it started getting a bit complicated. It seemed easier to produce different reports than to try to produce a "template" and figure out how to get each different report to work. Anyway, if you have thought it through better than me, I was thinking of the click event opening the report in design view, add the record source string to the Tag, and then open acPreview. Have the report's on open event contain something like me.recordsource = me.tag. Alternatively, if you would always open from the same form use an invisible text box on the form that contains the record source. me.recordsource = forms!FormName.txtRecSrc
Actually, just realised the above has too many stages. Open the report in design, set the record source to your desired query, then open. No need to use the tag.
What exactly do you need to do? Perhaps you would be best served by a parameter query? If the "template" of the report remains unchanged, as in all of the controls are in the same place and no physical changes occur, then you may be able to get by using just a parameter report instead of rebuilding your datasource from scratch every single time.