Solved

Dynamically sort ACCESS 2010 report with VBA

Posted on 2014-11-17
2
660 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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

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.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

763 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

10 Experts available now in Live!

Get 1:1 Help Now