Hi, Leo.
While entering the datas for the above fields in the form, if the status is
single then the form should skip the fields such as Husbands/wife/Father's
name, no of children, etc automatically and should go to the other fields.
If the status is Married then the form cursor should move to the field
Husband/wife/father name, no of children, etc.
Use the SetFocus method to jump to the appropriate text box. If you have a
combo box available for the user to select the status (recommended method to
avoid data entry errors), you could try the following syntax in your form's
code module:
Private Sub cboStatus_AfterUpdate()
On Error GoTo ErrHandler
If (Me!cboStatus.Column(1) = "Single") Then
Me!txtDOB.SetFocus
Else
Me!txtSpouse.SetFocus
End If
Exit Sub
ErrHandler:
MsgBox "Error in cboStatus_AfterUpdate( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear
End Sub
.... where cboStatus is the name of the combo box displaying the status,
Column(1) is the second column of the combo box (which displays the value
selected by the user), txtDOB is the text box displaying the date of birth,
and txtSpouse is the text box displaying the spouse's name.
However, if the form has a text box for the status, then try the following
syntax:
Private Sub txtStatus_AfterUpdate()
On Error GoTo ErrHandler
If (LCase$(Me!txtStatus.Value) = "single") Then
Me!txtDOB.SetFocus
Else
Me!txtSpouse.SetFocus
End If
Exit Sub
ErrHandler:
MsgBox "Error in txtStatus_AfterUpdate( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear
End Sub
.... where txtStatus is the name of the text box box displaying the status.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.