Passing OrderBy criteria from Form to Report

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I have quite a few continuous forms that, through right-clicking on various
fields, my users can customize to display the data exactly as they want.
This includes not only filtering records, but also sorting them.

I am able to easily duplicate the form into a report into which I can
correctly pass the forms Filter criteria. However, how can I pass the forms
OrderBy criteria to the report using VBA?

Right now, my code looks like...

docmd.openreport reportname, acviewpreview, , reportfilter, acwindownormal
on error resume next
docmd.selectobject acreport, reportname
docmd.runcommand accmdprint
docmd.close acreport, reportname, acsaveno

Obviously reportname and reportfilter are string variables.

Any help anyone can give would be most appreciated.
 
Brian said:
I have quite a few continuous forms that, through right-clicking on various
fields, my users can customize to display the data exactly as they want.
This includes not only filtering records, but also sorting them.

I am able to easily duplicate the form into a report into which I can
correctly pass the forms Filter criteria. However, how can I pass the forms
OrderBy criteria to the report using VBA?

Right now, my code looks like...

docmd.openreport reportname, acviewpreview, , reportfilter, acwindownormal
on error resume next
docmd.selectobject acreport, reportname
docmd.runcommand accmdprint
docmd.close acreport, reportname, acsaveno


Because report's are sorted according to your specifications
in Sorting and Grouping, you would need to use code in the
report's Open event to change the ControlSource property of
the GroupLevel entries.

Use the OpenReport method's OpenArgs argument to pass the
field names from the form to the report.
 
Back
Top