Toggle group of controls visibility with option buttons

  • Thread starter Matt Williamson
  • Start date
M

Matt Williamson

This is so easy in VB6.. not as easy in Access97

I'm simply trying to Toggle the visibility of 4 controls (2 labels and 2
DTPickers) based upon 2 option buttons in an option group. So far,
everything I've come up with isn't very elegant.

What is the easiest way to do this? All controls are unbound. I tried using
the mouseup/down keyup/down events, but it seems like a lot of unnecessary,
redundant code.

TIA

Matt
 
K

Kelvin

The value of the option buttons will either be true or false depending on if
it is selected so set the visibility of the controls to equal the value of
the option depending on your logic. Place in the OnCurrent event of the
form and the afterupdate event of the option buttons.

Me.Control1.Visibility = Me.Option1
Me.Control2.Visibility = Not Me.Option1
so on...

Kelvin Lu
 
M

Matt Williamson

Kelvin-

That makes a lot more sense, but I'm not seeing any of those events for the
mentioned controls. My option buttons only have Got/Lost focus and the Key
and Mouse events. My Form doesn't have an OnCurrent event either. What am I
missing here? This is for Access97 right?

TIA

Matt
 
K

Kelvin

Matt,

I used the wrong command, its Visible not Visiblity. The code would only
work if your options were individual Option Buttons. For an option group
you will have to set Visible manually. Put it into the Got Focus event of
each button. For example, if you want controls 1 and 2 to be visibile and 3
and 4 to not if option 1 is chosen, put into option 1

Control1.Visible = True
Control2.Visible = True
Control3.Visible = False
Control4.Visbile = False

If you prefer the code I provided earlier, get rid of the option group and
put in2 individual option buttons. Put in the code from before and also add
a line to change the value of the other option button

OptionButton2 = not(OptionButton1)

Flip everything around for the other option for either method you choose to
use.

Kelvin Lu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top