Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dynamically sort ACCESS 2010 report with VBA

Posted on 2014-11-17
2
Medium Priority
?
876 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

705 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