Solved

Change report name with VBA in ACCESS 2013

Posted on 2014-11-06
8
385 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
A short article about problems I had with the new location API and permissions in Marshmallow
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…
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…

867 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

24 Experts available now in Live!

Get 1:1 Help Now