With Reports Statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to open a Report and at the same time change a lable control
"lblControlHidingForm" on the report using the With Statement. Below is the
code I am using but the labels' caption is not displaying the text
"frmMainSwitchboard".

DoCmd.OpenReport "Company Directory", acViewPreview, , ""
With Reports("Company Directory")
.lblControlHidingForm = "frmMainSwitchboard"
End With
 
Put the code in the report's Open event

Me.lblControlHidingForm = "frmMainSwitchboard"
 
This was the code I was using I just wanted to see if I can use the With
Statement instead. I appreciate you responding, thanx again!
 
I am trying to open a Report and at the same time change a lable control
"lblControlHidingForm" on the report using the With Statement. Below is the
code I am using but the labels' caption is not displaying the text
"frmMainSwitchboard".

DoCmd.OpenReport "Company Directory", acViewPreview, , ""
With Reports("Company Directory")
.lblControlHidingForm = "frmMainSwitchboard"
End With

It's a question of timing, as well as an improper attempt to change
the Caption of a label control without addressing the label's caption
property.

DoCmd.OpenReport "Company Directory", acViewDesign
With Reports("Company Directory")
.lblControlHidingForm.Caption = "Switchboard"
End With
DoCmd.Close acReport, "Company Directory", acSaveYes
DoCmd.OpenReport "Company Directory", acViewPreview

The above will permanently change the label caption to "Switchboard".
If you have other forms opening the same report, you will need to use
the same method to again change the label caption to something else.
 
Still needs to be in the report code

With Me.
.lblControlHidingForm = "frmMainSwitchboard"
End With

You could use fredg's method, but you talk about ssslllloooowwww!
Why open the report, modify it, and save it when you don't need to.

The With statement is really great when you have multiple things to do with
the object. It is easier to read and executes faster, but for one operation
on one object, there really is no point.
 
Back
Top