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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename a label based on certain conditions in Access Report 1

Status
Not open for further replies.

titanl

Technical User
Apr 13, 2009
23
SC
Hi. Have been trying to rename a label in access report based on certain criteria. I can easily do it in Access Forms using VBA but I can't in Report.
The problem is like this: I have a textbox and label "Startlist" minus quotation marks. I want the caption of the label to be "Order" for Field event eg Long Jump or "Lane" for Track event eg 100m.
The code I've been using is like this:

Private Sub Report_Open(Cancel As Integer)
DoCmd.Maximize

If Me.Type = "Field" Then
Me.StartList_Label.Caption = "Start List"
Else
Me.StarList_Label.Caption = "Lane"
End If

End Sub

NB; Type is a field in the table for either "Field" or "Track" Event.

Thanks for the help.
 
Your code should be in the On Format event of the section of the report containing the control/label. I would probably replace the label with a text box and set the control source to:
Code:
=IIf([Type] = "Field","Start List","Lane")

Duane
Hook'D on Access
MS Access MVP
 
Hi dhookom!
Thanks a million! Your advice works beautifully!
10 out of 10 for such a lightning response (below 1 hour)!
You made my day. Thanks again.
By the way will try the 2nd advice and let you know if it works.

titanl
 
Hi dhookom!
Tried the 2nd method with the text box and it works like a charm. Brilliant! Thanks again.

titanl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top