Setting a control property based on a selection

Dimples

Registered User.
Local time
Today, 18:43
Joined
Aug 19, 2005
Messages
15
Ok, here is my question. I am just a little rusty since it has been a while since I have been in Access.

So I have a option group: option 1, option 2, option 3

If option 1 is selected I want textbox 1 visible, but textbox 2 and 3 not visible.

If option 2 is selected I want textbox 2 visible, but textbox 1 and 3 not visible.

If option 3 is selected I want textbox 3 visible, but textbox 1 and 2 not visible.

When the form first opens, all textboxes are not visible. What is the correct way to do this: code, macro, etc? and where should I place it? Should it be in the Afterupdate property of the option group?

Thanks!!
 
Set the after update query of the option group to trigger the appropriate code depending on the return.

If Frame1.Value = 1 Then
me.txt1.visible = true
me.txt2.visible = false
me.txt3.visible = false
End If
If Frame1.Value = 2 Then
me.txt1.visible = false
me.txt2.visible = true
me.txt3.visible = false
End If
If Frame1.Value = 3 Then
me.txt1.visible = false
me.txt2.visible = false
me.txt3.visible = true
End If

dont forget to set the on open [properties of the form to include
me.txt1.visible = false
me.txt2.visible = false
me.txt3.visible = false

just to make sure they do not remain visible.
 

Users who are viewing this thread

Back
Top Bottom