Report vba scripting (1 Viewer)

Espinoza84

Registered User
Joined
May 30, 2008
Messages
55
Hello, I cant figure this one out:

I have a textbox with control source [APPLICATION], when I run/execute the report, depending on the persons name and etc etc, the application will display either: house, hospital, or car.

At the same time I have 2 labels: Label1 and Label2. Nothing is bound btw.

What do I do if I want to hide Label1 (visible=false) but display Label2, if the result of the textbox with source [APPLICATION] is "house". and hide Label2 and display Label1, if the result of the textboxt with source [APPLICATION] is "hospital"

Can someone please code this for me?
 

KenHigg

Registered User
Joined
Jun 9, 2004
Messages
13,309
Several ways to do this. One is having both labels visible property set to false, put the following code in the reports on open event:

if me.application = "house" then
me.Label2.visible = True
else
me.Label1.visible = True
end if

Would this work for you?
 

Espinoza84

Registered User
Joined
May 30, 2008
Messages
55
thanks, I did this for my purposes:
Me.Label53.Visible = False
Me.Label85.Visible = False
If Me.Application = "House" Then
Me.Label53.Visible = True And Me.Label85.Visible = False
Else
Me.Label85.Visible = True And Me.Label53.Visible = False
End If

Because, my report is in DETAIL section and it loops so i needed to reset the labels back to false.
 
Last edited:

Espinoza84

Registered User
Joined
May 30, 2008
Messages
55
Now, that it is understood what I am trying to accomplish.

My real problem is that, I have a subreport in this report.

imagine the textbox [APPLICATION] is in the subreport, while the labels are in the main report (not in the subreport). Can I still accomplish my goal with the visibles(true/false) ?

Thank you in advance
 

KenHigg

Registered User
Joined
Jun 9, 2004
Messages
13,309
You should be able to, you just need to refer to the controls a little bit differently:

Me!mysubformname.form!Application = "House"
 

evanscamman

Registered User
Joined
Feb 25, 2007
Messages
274
How about this:

Code:
dim blnShow as Boolean
if Me!mysubformname.form!Application = "House" then
    blnShow = True
else
    blnShow = False
end if
 
Me.Label53.visible = blnShow
Me.Label58.visible = Not blnShow
Evan
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom