Solved

Dynamically sort ACCESS 2010 report with VBA

Posted on 2014-11-17
2
693 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now