Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordsource of report

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How do you set the recordsource of a report in VB? I tried to set the recordsource before the report is opened and get an error that says the report isn't open.

[Reports]![[RptContacts].Recordsource = "Select..."
DoCmd.OpenReport "RptContacts", acViewPreview

I tried to set the recordsource after the report is opened and get an error that you can't set the recordsource after printing has started.

DoCmd.OpenReport "RptContacts", acViewPreview
[Reports]![[RptContacts].Recordsource = "Select..."

What gives???? Is there a way to open the report without printing it, set the recordsource, and then print?

TIA!
 
You need to set the recordsource in the On Open event of the report.
Set the recordsource like this:

Me.Recordsource = "Select..."


You still would open the report like this:

DoCmd.OpenReport "RptContacts", acViewPreview
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top