Solved

Change report name with VBA in ACCESS 2013

Posted on 2014-11-06
8
368 Views
Last Modified: 2014-11-11
I have a report that is used by several areas.  I do not want to create five different reports.  I can pass critieris to filter the data, but how to I change the reports title label to read, say, "South", when it is opened?

Sandra
0
Comment
Question by:ssmith94015
8 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 40427399
how are opening the report? post your codes.

you can use Tempvars collection to store the name for yuor report's label

Tempvars.add "myLabel", "<your variable filter here>"

in the open event of your report, or in the print event of the section of the report where you placed the label

place this codes

me.labelName.caption=tempvars!myLabel
0
 

Author Comment

by:ssmith94015
ID: 40427448
I inherited this project and the report is opened with the DoCmd.OpenReports.  Which report depends on which item in a listbox the user selects. So far, I have the below

                       Case 8:  DoCmd.OpenReport "rptAreaReports", acViewReport, , "Zone = ''EU South'' "
                                Reports("rptAreaReports").lblCaption.Properties("caption").Value = "South"

Sandra
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 40427481
are you opening just one report, "rptAreaReports" ?

post the whole codes related to the opening the report.
0
 

Accepted Solution

by:
ssmith94015 earned 0 total points
ID: 40427491
Actually, I got it to work with the OpenArgs argument in the statement so I am good.  Thanks.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 30

Expert Comment

by:hnasr
ID: 40427509
calling report: pass required title as openArgs of the report.
DoCmd.OpenReport "yourReport", acViewReport, ,,,,"South"

Open event of report:
Private Sub Report_Open(Cancel As Integer)
    Me.titleLabel.Caption = Me.OpenArgs
End Sub
0
 
LVL 84
ID: 40432974
Your solution doesn't really provide any details - could you perhaps post the codes you're using to do this, so other may benefit from it?
0
 

Author Comment

by:ssmith94015
ID: 40433109
Below is the new code.  I just found out from the client that ALL the reports are the same structure, so will be using the pattern for Cases 5,6,7,8,9 for the other report calls

With Me.lstReports
             For I = 0 To .ListCount - 1
                 If .Selected(I) Then
                     Select Case I
                       Case 0:  DoCmd.OpenReport "DealSummary", acViewReport
                       Case 1:  DoCmd.OpenReport "ActivityRpt", acViewReport
                       Case 2:  DoCmd.OpenReport "PartnerRpt", acViewReport
                       Case 3:  DoCmd.OpenReport "ActionDueWeekRpt", acViewReport
                       Case 4:  DoCmd.OpenReport "ActionDueMomthRpt", acViewReport
                       Case 5:  DoCmd.OpenReport "rptAreaReports", acViewPreview, , "ZSM = 'NA East' ", , "Noth America Eastern Zone"
                       Case 6:  DoCmd.OpenReport "rptAreaReports", acViewPreview, , "ZSM = 'NA West' ", , "Noth America Western Zone"
                       Case 7:  DoCmd.OpenReport "rptAreaReports", acViewPreview, , "ZSM = 'EU West' ", , "Western Europe"
                       Case 8:  DoCmd.OpenReport "rptAreaReports", acViewPreview, , "ZSM = 'EU South' ", , "Southern Europe"
                       Case 9:  DoCmd.OpenReport "rptAreaReports", acViewPreview, , "ZSM = 'JPN' ", , "Japan Zone"
                       Case 10: DoCmd.OpenReport "InactiveRpt", acViewReport
                     End Select
                     Exit For
                 End If
             Next
        End With
0
 

Author Closing Comment

by:ssmith94015
ID: 40434614
Solved issue myself.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now