Solved

Change report name with VBA in ACCESS 2013

Posted on 2014-11-06
8
399 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Expert Comment

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

post the whole codes related to the opening the report.
0
Back Up Your Microsoft Windows Server®

Back up 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.

 

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
 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can you open the FORM2 2 32
SetFocus doesn't wait for input 14 34
Modify report 8 11
Visible ppty on rpt 7 7
A short article about problems I had with the new location API and permissions in Marshmallow
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.

832 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