Label Visibility VBA (1 Viewer)

pwicr

Registered User.
Local time
Today, 13:44
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....
 

pwicr

Registered User.
Local time
Today, 13:44
Joined
Sep 22, 2011
Messages
144
While I was waiting I kept looking and found one that did work...so happy I want to cry!!!

Thanks for your reply Paul
 

pwicr

Registered User.
Local time
Today, 13:44
Joined
Sep 22, 2011
Messages
144
crap. weird...worked in layout view and then not in PRint preview...will try yours now Paul
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:44
Joined
Aug 30, 2003
Messages
36,140
Note that the format events only fire in Preview and Print views, not the Report view (not sure about Layout, but I doubt it).
 

pwicr

Registered User.
Local time
Today, 13:44
Joined
Sep 22, 2011
Messages
144
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
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:44
Joined
Aug 30, 2003
Messages
36,140
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.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:44
Joined
Aug 30, 2003
Messages
36,140
The format event of the section (it's in the property window of the section).
 

pwicr

Registered User.
Local time
Today, 13:44
Joined
Sep 22, 2011
Messages
144
I've selected the Events tab...there is a lot of events to chose from
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:44
Joined
Aug 30, 2003
Messages
36,140
The On Format event.
 

pwicr

Registered User.
Local time
Today, 13:44
Joined
Sep 22, 2011
Messages
144
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.
 

MayaMana

Registered User.
Local time
Today, 15:44
Joined
May 29, 2012
Messages
60
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.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:44
Joined
Aug 30, 2003
Messages
36,140
What view are you using? The format event only fires in Preview and Print views.
 

pwicr

Registered User.
Local time
Today, 13:44
Joined
Sep 22, 2011
Messages
144
I always try in Print Preview.

Tried the MayaMana code and got

Run-Time error "13"
Type mismatch
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:44
Joined
Aug 30, 2003
Messages
36,140
Did you try mine? Can you post the db here?
 

Users who are viewing this thread

Top Bottom