Label Visibility VBA

pwicr

Registered User.
Local time
, 22:26
Joined
Sep 22, 2011
Messages
144
:banghead:

I've tried 3 different codes and can't get my VBA to work...

I have a report...on this report I have a label. I have the visibility property set to NO. BUT....IF the "FUELTYPE" combo box on the report is "DIESEL" then I want the visibility to change to YES

Eyes are bugging out....
 
While I was waiting I kept looking and found one that did work...so happy I want to cry!!!

Thanks for your reply Paul
 
crap. weird...worked in layout view and then not in PRint preview...will try yours now Paul
 
Note that the format events only fire in Preview and Print views, not the Report view (not sure about Layout, but I doubt it).
 
tried this....didn't work.


Private Sub lblUPSINVNAFTASTMT()

If Me.FUELTYPE = "Diesel" Then
Me.lblUPSINVNAFTASTMT.Visible = True
Else
Me.lblUPSINVNAFTASTMT.Visible = False
End If

End Sub

I only want to print the Label if the Fuel Type is Diesel
 
Did you miss this?

On a report, you'd want it in the format event of the section containing the controls.

Presumably that's the detail section.
 
The format event of the section (it's in the property window of the section).
 
I've selected the Events tab...there is a lot of events to chose from
 
sigh. sorry Paul. I was clicked on the wrong square and was looking at the report event tab instead of the detail tab. I had been staring at the screen most of the afternoon and eyes were buggy.

I'm fresh this a.m. I tried "On Format" in the DETAIL section (just like you said) and it still isn't working.
 
Hey try:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.lblUPSINVNAFTASTMT.Visible = Nz(Me.FUELTYPE, "Diesel")
End Sub
It will still show up in report view, but it will not print it.
 
What view are you using? The format event only fires in Preview and Print views.
 
I always try in Print Preview.

Tried the MayaMana code and got

Run-Time error "13"
Type mismatch
 
Did you try mine? Can you post the db here?
 

Users who are viewing this thread

Back
Top Bottom