skipping field if first field = No or Unknown

C

cbhealth

I have had a request to set up a form that will skip two or three fields if
the first field is no. Is there a way I can do this?
 
J

John Vinson

I have had a request to set up a form that will skip two or three fields if
the first field is no. Is there a way I can do this?

Clarification please. What is the datatype of the "first field" (note
that Forms don't have fields; they have Controls, I presume you mean
the first control in the tab order)? When is it decided whether this
field is Yes or No - is there data already stored, or do you want to
change the navigation after a choice is made? Just what do you mean by
"skip" - have the focus go to the next field after these, disable the
controls, make them invisible?

John W. Vinson[MVP]
 
C

cbhealth

The control is a combo box with three choices - yes, no or unknown. When
data is entered on a new record and the choice is "No", the data enterer
would like to skip the next few controls as they relate to the first control
being answered yes.
They do not have to be invisable, but the cursor would skip over them to the
next unrelated question. It is not necessarily the first control on the form
though.

For instance: If the control asks "Is the client pregnant?" and "No", or
"Unknown" is the choice made for the combo box, then the controls for "how
many months" , and "Is this the first pregnancy?", could be skipped or not
tabbed to by the cursor and go to a different control. If the answer is yes,
then the cursor would follow the tab order set.

I hope this makes sense - and Thanks
 
J

John Vinson

For instance: If the control asks "Is the client pregnant?" and "No", or
"Unknown" is the choice made for the combo box, then the controls for "how
many months" , and "Is this the first pregnancy?", could be skipped or not
tabbed to by the cursor and go to a different control. If the answer is yes,
then the cursor would follow the tab order set.

Thanks, much clearer!

You can use VBA code in the combo box's AfterUpdate event:

Private Sub comboboxname_AfterUpdate()
If Me.comboboxname = "No" OR Me.comboboxname = "Unknown" Then
Me.txtXYZ.SetFocus
End If
End Sub

where txtXYZ is the name of the control to which you want to skip.

John W. Vinson[MVP]
 
C

cbhealth

Thanks

John Vinson said:
Thanks, much clearer!

You can use VBA code in the combo box's AfterUpdate event:

Private Sub comboboxname_AfterUpdate()
If Me.comboboxname = "No" OR Me.comboboxname = "Unknown" Then
Me.txtXYZ.SetFocus
End If
End Sub

where txtXYZ is the name of the control to which you want to skip.

John W. Vinson[MVP]
 
Top