Solved

Dynamically sort ACCESS 2010 report with VBA

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

809 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