Passing OrderBy criteria from Form to Report

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.
 
M

Marshall Barton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top