Dynamically sort ACCESS 2010 report with VBA

I have a form that users can select the sort order, but how to I pass this information to the open report statement?

Who is Participating?
quizwedgeConnect With a Mentor Commented:
Found this over at http://www.dbforums.com/showthread.php?1099710-Changing-the-Reports-Sort-Order-with-VBA-Code

you can simple sort your report by modifying Order by property in open event of your report. something like:

to sort by "Names" field in on click event of your button that fires the report;
      DoCmd.OpenReport "YourReportName", acViewPreview, , , , "Names"
then in Open event of your Report;
Me.OrderBy = Me.OpenArgs
Me.OrderByOn = True
ssmith94015Author Commented:
Works but I have an additional problem in that I already pass the name of the report in its caption using the Open Args.  So, I need to pass two items in open args.

    DoCmd.OpenReport strReportName, acViewReport, , strFilter, , strReportCaption

Private Sub Report_Open(Cancel As Integer)
    Me.lblTitle.Caption = Me.OpenArgs
End Sub

Will post as another question as you did answer the one I asked.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.