Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on 

How to pass multipe items in OpenArgs event of an ACCESS 2010 report

I pass the name of the report in its caption using the Open Args.  But, I need to pass two items in open args.  One to dynamically change the report title and an argument to change the sort order.  Right now, I pass the caption, but how to I add a second argument?

    DoCmd.OpenReport strReportName, acViewReport, , strFilter, , strReportCaption

Private Sub Report_Open(Cancel As Integer)
    Me.lblTitle.Caption = Me.OpenArgs
   
End Sub

Need to add in the Report_Open event
     Me.OrderBy = Me.OpenArgs
     Me.OrderByOn = True
Will post as another question as you did answer the one I asked.

Sandra
Microsoft AccessMicrosoft DevelopmentProgramming

Avatar of undefined
Last Comment
Sandra Smith
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Sandra Smith
Sandra Smith
Flag of United States of America image

ASKER

Yes, the looks familiar.  I knew I had done this in one of my other databases, but simply could not remember which one and how.  They you for jogging my memory and I know this approach does work, I just could not remember it!

Sandra
and just as an FYI, you can come up with all kinds of schemes.  For example:

"ADD;SETCTRLTODATA=txtCustomerID:" & NewData & ";EXITTOFORM=frmLoad"

This is a string I pass to a form in OpenArgs.   I'm using the semi-colon as a delimiter.

First argument is the mode the form should open in.   Second specifies that the following control/value pairs should be set, and the third is the form that focus should be returned to when closed.

Whatever you do, don't rely on position (i.e. 3rd argument in is this xxxx), but rather use a 'tag' (i.e. 'SETCTRLTODATA=') to tell you what the argument is.  

So in your case, maybe:

"SETCAPTION=<value>|SORTORDER=<value>"

Then your report open can be standardized looking for each thing that needs to be done as you should do it:

1. Do I need to set the caption?  Look for the tag.  not found, do nothing.  Found, set.
2. Do I need to set the sort order? Look for the tag....

or you can loop through the array after a Split() and act on each tag in turn.

Jim.
Avatar of Sandra Smith
Sandra Smith
Flag of United States of America image

ASKER

Thank you for the follow up and I learned a long time ago not to rely on position!  When I inherited this database, there was a report for every scenario, the same report, but now I just have one to worry about and pass the needed filter and arguments.  Easier to maintain the one now than 15 copies.  I use the pipe as I can see it better, but important thing is it does get the job done.

Sandra
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo