Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Dynamically sort ACCESS 2010 report with VBA

Posted on 2014-11-17
2
Medium Priority
?
923 Views
Last Modified: 2014-11-17
I have a form that users can select the sort order, but how to I pass this information to the open report statement?

Sandra
0
Comment
Question by:ssmith94015
2 Comments
 
LVL 14

Accepted Solution

by:
quizwedge earned 2000 total points
ID: 40448156
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;
Code:
      DoCmd.OpenReport "YourReportName", acViewPreview, , , , "Names"
then in Open event of your Report;
Code:
Me.OrderBy = Me.OpenArgs
Me.OrderByOn = True
0
 

Author Closing Comment

by:ssmith94015
ID: 40448168
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.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
Six Sigma Control Plans
Loops Section Overview

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question