Go to field depending on check box choice

ronda

Registered User.
Local time
Today, 06:51
Joined
May 5, 2002
Messages
19
I have a option group setup with 2 checkboxes inside(yes, designate or No, do not designate) . What I want to do is if the user has checked yes designate, it requires 2 fields to be filled out(physician_name, city), if they select no, do not designate, I want it to go directly to my submit button bypassing the above mentioned fields.
 
OptionGroupName OnClick()

If OptionGroupName = 2 Then ' NO
PhysicianName.Enabled=False
City.Enabled=False
CommandButtonName.SetFocus
Else ' YES
PhysicianName.Enabled=True
City.Enabled=True
PhysicianName.SetFocus
End If
 
Thanks for your quick response Kevin
1 question reg the onclick event.
When I select the yes response I would like to make the physician_name a required entry (but only if they answered yes in the check box).
Also, when I answer no to the check box and it greys the text box out, the labels also seem to get fuzzy and hard to read. Is that supposed to happen?
 
It is.

Replace 'Enabled' with 'Locked' in all cases.

Not sure if you can set it to 'required' at run-time?
 
error trapping before submit

Help! The last thing I need to complete this....

When the user selects yes on the check box and hits tab it goes to the physician_name and all of the other fields needed(thanks to Kevin!).
Apparently if they click yes on the check box and go and click on the submit button (instead of hitting tab), the data will still go through. I need to double check before hitting the submit button that if the box was checked yes, the physician_name must be filled in, otherwise, its fine.
 
Off the top of my head (there may be a better way)....

cmdButton OnClick()

If IsNull(PhysicianName) And OptionGroupName = 1 Then
PhysicianName.SetFocus
Else
....Code to carry out onclick etc

End If
City.Enabled=False
End Sub

You may want to put a msg box in there to inform users that they MUST enter a Pysician Name.

HTH
 
Thanks so much Kevin - I'm finally done with this project!!!!
:D
 

Users who are viewing this thread

Back
Top Bottom