Solved

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

Posted on 2014-11-17
4
275 Views
Last Modified: 2014-11-17
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
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
  • 2
4 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 40448191
The simplest is to choose a delimiter, say a vertical pipe, and do:

<caption>|<other value>|<othervalue>

then use Split() in the receiving object to split the string into an array.

Jim.
0
 

Author Closing Comment

by:ssmith94015
ID: 40448217
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
0
 
LVL 57
ID: 40448223
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.
0
 

Author Comment

by:ssmith94015
ID: 40448284
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
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
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…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

749 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