Hiding text boxes based on option button

  • Thread starter Thread starter Brian Hubley
  • Start date Start date
B

Brian Hubley

Guest
Any help would be greatly appreciated, I've been racking my brain trying to make this work. I have a option button (Cancelled) that when it is Null, I would like the text box (Cancel Date) to be hidden; when checked then display the text box.

Not to get greedy in my quest for knowledge, but would the process be any different for a option button to control a combo box?
Thanks
Brian
 
You can try this. On your form go to the Timer Interval and set it at 1000. Then on then put the following on the ONTIMER event:

If Me.PendingMember = -1 Then
Me.CancelDate.Visible = True
Else
Me.CancelDate.Visible = False
End If

You can play with that. The -1 can be yes or is notnull. Try differet ways until it works.
 
Rather than the Timer, use the Form's Current event.
Code:
Private Sub Form_Current()
    If Me.OptionGroup = 2 Then Me.txtBox.Visible = True
End Sub

HTH,
David R
 
Thank you both for responding. I have tried both methods, unfortunatly I was unsuccessful in hidding or making the text box visable. It looks like an either or situation. Do you have any more suggestions?
Brian
 
You may need to place similar code in the AfterUpdate event of your option group. Make sure it accounts for both making it visible and hiding it. (If your field is saved as invisible, then the form will only need make it visible when the condition is met).

We're not talking about a continuous subform are we? There's known problems with making fields selectively invisible on those.

David R
 
The easiest way is to put the following code under the forms Activate property:

nameoftextbox.visible=false
i.e. txtCancelDate.visible=false

This will 'hide' the text box when the form is displayed. Then on the on_click event of the option button have the following code:

nameoftextbox.visible=true
i.e. txtCancelDate.visible=true

This will also work for combo boxes.

HTH
Dave
 

Users who are viewing this thread

Back
Top Bottom