on click for cmds

pascaly

Registered User.
Local time
Today, 22:10
Joined
Jan 29, 2008
Messages
28
Hi,

code noobie, so would love some help here.

I have a form with several controls (mostly txt and chk). When I click a cmd, I have set some of the controls to Visible = False and some to Visible = True depending on what the user needs to see at the time.

What I'd like to do, is if the user clicks this same cmd again, the form reverts back to the previous view, and they can switch between the two views of the form as many times as they like.

I think the code goes on the On Click event, just not sure what I need! Any help greatly appreciated.

If I'm not clear, please let me know, thanks.
 
One option would be a toggle button instead of a normal button. You test the value of the button and set your values appropriately. I think there's sample code in VBA help.
 
I do this quite often...and what I do is extremely manual. Here is an example of what I do if you want to use it:
Code:
me.control1.visible = false
me.control2.visible = false
me.control3.visible = false

me.control4.visible = true
me.control5.visible = true
me.control6.visible = true

me.cmdbutton.caption = "Switch to View #2"
 
When you click on the command button use the code

Me.ControlName.Visible = Not Me.ControlName.Visible
 
Funny, I'm usually the one who posts the one-line boolean logic solution. It slipped my mind this time. Good catch.
 
Great, thanks everyone, I haven't tried it yet, but thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom