I know that you can set the recordsource of a report at runtime, using something like.

rptProject.recordsource= "Select * from Project"

however, what happens if you do not know the name of the report at design time?

I have several reports which are loaded in to a combo box. The user can then select the report to view. How then do I set the recordsource of the selected report?

What I have so far is:
VB Code:
  1. If IsNull(cmbReports.Value) Then
  2.     MsgBox "You must select one of the reports.", vbOKOnly + vbCritical, conMsgTitle
  3.     cmbReports.SetFocus
  4. Else 'there is a report selected
  5.     DoCmd.OpenReport cmbReports.Value, acViewPreview
  6. End If

Thanks

Francis