Question Locked

Report RecordSource property issue in Access 2002

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a need to change the saved Report's RecordSource property from VBA code. The record source is one of several saved queries. when the user clicks a command button on a form, the code checks which is the appropriate query to run, and then need to set the RecordSource for a specified report.

The issue I have is when I assign the RecordSource property value in VBA code, I get en error message "You cant set a record source property in print preview or after printing has started." It seems that by assigning the value in format of:
Report_Name.RecordSource = variableName, the code causes the report to be opened.

I need to change the RecordSource property value, then run the report: DoCmd.OpenReport stDocName, acPreview.

Any help on achieving the goal of changing RecordSource property of a report from VBA code in Access 2000 is appreciated.

2 replies

by ag691234

The cause of the problem: I was trying to change the Report's RecordSource property from the code activated by the click of a command button on a form. Instead I needed to move the logic to the code activated by the OnOpen event of the form.

Simple mistake which gave me big headache, simple to fix and to avoid.

This discussion is closed to new replies.