Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass value to label in report header

Status
Not open for further replies.

annie52

Technical User
Mar 13, 2009
164
US
Why can't I pass a value to a label on a report? I put lblAction in the report header but it's not showing up as expected.

Dim stDocName As String, stSelectTech As String

stDocName = "rptFollowup"
stSelectTech = "Tech='" & Forms![frmTechnician]![cboTechnician] & "'"
DoCmd.Close acForm, "frmTechnician", acSaveNo
If stSelectTech = "Tech='All Technicians'" Then
DoCmd.OpenReport stDocName, acViewPreview
Reports![rptFollowup]![lblAction].Caption = "All Technicians"
Else
DoCmd.OpenReport stDocName, acPreview, , stSelectTech
Reports![rptFollowup]![lblAction].Caption = stSelectTech
End If
 
After the report is in preview is too late, you can use the Open event of the form to change the label, or you can hide the form and refer directly to it on the report.

 
A really simple method is to use a text box on the report that references the Filter property of the report:
[tt][blue]
Control Source: =IIf([FilterOn]=True And Len([Filter])>0,[Filter],"No Filter")
[/blue][/tt]

Duane
Hook'D on Access
MS Access MVP
 
Thanks, Remou. That makes perfect sense. Here's what I ended up with in the report's OnOpen event:

stSelectTech = Forms![frmTechnician]![cboTechnician]
lblActionTech.Caption = "Action Items For " & stSelectTech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top