How to change a report recordsource?

  • Thread starter Thread starter Gary
  • Start date Start date
Hi,

How to change a report recordsource base on a form field.

Thank for help!!

Gary

It depends.
When you supply a bit more information as to what, when, and where,
we'll be able to supply a bit more of an answer as to how.
 
I store different query name in a form combo box, so when open a report the
recordsource can change base on the form combo box.

Gary
 
I store different query name in a form combo box, so when open a report the
recordsource can change base on the form combo box.

Gary

If the form is open when you open the report:
Code the report's Open event:
Me.Recordsorce = forms!FormName!ComboName

Alternatively code an event on the form:
DoCmd.OpenReport "ReportName", acViewPreview
reports!ReportName.RecordSource = Me!ComboName

Wouldn't it be easier to just have just one record source, and use the
Where clause argument of the OpenReport method to filter the records?
For example...

DoCmd.OpenReport "ReportName",acViewPreview, , "[CompanyID] = " &
Me[CompanyID

It's simple enough to change the Where clause to whichever field(s)
you want to filter on.
 
Back
Top