|
-
Aug 23rd, 2005, 09:54 AM
#1
Thread Starter
Frenzied Member
ACCESS: How To: Set Label Caption in a Report [RESOLVED: OpenArgs]
Esteemed Forum Participants and Lurkers:
===============================
ACCESS '02, '03
I have a common Report format for 4 different Departments, and in the code with the 'Department Selector' buttons I am trying to change one of the Labels in the report "Page Header" to reflect the different department selection. I have tried many approaches, but nothing seems to work yet. Here is what I am working with now:
Added Note: The following code does PRINT correctly, and it also displays correctly on pages 2 and above for multiple pages. It just doesn't affect Page 1 displayed in a window!!!
Code:
Private Sub Command0_Click()
Dim aWhere As String
'Select a WHERE statement (from Global List) based on the Radio Button Group
aWhere = aDept(Form1.Grp_Dept.Value)
'This successfully opens a window with the correct Report
DoCmd.OpenReport "Price_1", acViewPreview, , aWhere, acWindowNormal
'''TEST TEST TEST TEST This WORKS
MsgBox Reports("Price_1").Controls("Dpt_Label").Caption
'''END TEST
'Can a Report be changed once it is open??? This doesn't change anything!
Reports("Price_1").Controls("Dpt_Label").Caption = "TEST 1"
End Sub
Any and all comments, suggestions, and assistance is sincerely appreciated.
Last edited by Webtest; Aug 23rd, 2005 at 12:03 PM.
Reason: RESOLVED
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
Aug 23rd, 2005, 12:01 PM
#2
Thread Starter
Frenzied Member
Re: ACCESS: How To: Set Label Caption in a Report ???
Hey, MethadoneBoy's question about passing a parameter was the inspiration I needed!
I solved the problem by passing the new text for the Label.Caption in the "OpenArgs" parameter in the OpenReport command, and used the Open Event for the Report to install the new Caption. It works great!
Code:
'>>> In Control Form Module
Private Sub Command0_Click()
Dim aWhere As String
Dim aStrArg As String
'Select a WHERE statement (from Global List) based on the Radio Box Group
aWhere = aDept(Me.Dpt_Chain.Value)
'Pass a String Argument to the Report to install in the Label
aStrArg = "TEST 22"
'Open the Report and pass it a string ...
DoCmd.OpenReport "Price_1", acViewPreview, , aWhere, acWindowNormal, aStrArg
End Sub
'>>> In Report Code - Form opens with "TEST 22" in the Label
Private Sub Report_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then
Me.Controls("Dpt_Label").Caption = Me.OpenArgs
End If
End Sub
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|