Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 05-30-2008, 08:53 AM   #1
Espinoza84
Registered User
 
Join Date: May 2008
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Espinoza84 is on a distinguished road
Report vba scripting

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?

Espinoza84 is offline   Reply With Quote
Old 05-30-2008, 09:20 AM   #2
KenHigg
Registered User
 
Join Date: Jun 2004
Posts: 13,309
Thanks: 8
Thanked 184 Times in 158 Posts
KenHigg has a spectacular aura about KenHigg has a spectacular aura about
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?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

ken

“You don’t learn to walk by following rules. You learn by doing, and by falling over.”
KenHigg is offline   Reply With Quote
Old 05-30-2008, 10:26 AM   #3
Espinoza84
Registered User
 
Join Date: May 2008
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Espinoza84 is on a distinguished road
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 by Espinoza84; 05-30-2008 at 10:37 AM.
Espinoza84 is offline   Reply With Quote
Old 05-30-2008, 10:34 AM   #4
Espinoza84
Registered User
 
Join Date: May 2008
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Espinoza84 is on a distinguished road
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
Espinoza84 is offline   Reply With Quote
Old 05-30-2008, 04:26 PM   #5
KenHigg
Registered User
 
Join Date: Jun 2004
Posts: 13,309
Thanks: 8
Thanked 184 Times in 158 Posts
KenHigg has a spectacular aura about KenHigg has a spectacular aura about
You should be able to, you just need to refer to the controls a little bit differently:

Me!mysubformname.form!Application = "House"
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

ken

“You don’t learn to walk by following rules. You learn by doing, and by falling over.”
KenHigg is offline   Reply With Quote
Old 05-30-2008, 07:37 PM   #6
evanscamman
Newly Registered User
 
Join Date: Feb 2007
Posts: 274
Thanks: 0
Thanked 1 Time in 1 Post
evanscamman is on a distinguished road
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

evanscamman is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Use VBA to CREATE a report modest Reports 24 03-15-2012 12:45 AM
VBA to refresh,reload,requery a report? MsLady Modules & VBA 10 04-05-2009 01:24 AM
open and filter report from vba Mr.K Modules & VBA 2 10-25-2006 04:12 PM
Help linking VBA to a report keving Modules & VBA 2 03-07-2003 06:44 AM




All times are GMT -8. The time now is 09:41 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World