M
Melinda
I have a form that requires an answer to every question on the form. The
answers are either, "Yes", "No", or "Undetermined". If the user answers
"Undetermined" I have a text box that appears that requires a comment.
I have code in the form's BeforeUpdate property that checks for (1) the
initial answers and (2) for the comments to be completed in any question with
an "Undetermined" answer. What I want is for the code to pause between the
two to allow the user to complete the missing fields. Help. Here is my code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ctl As Control
Dim blnContinue As Boolean
blnContinue = True
For Each ctl In Me.Controls
If ctl.Tag = "Required" Then
If IsNull(ctl) Then
MsgBox "You must complete the " _
& ctl.ControlSource & " field."
Cancel = True
ctl.SetFocus
Exit For
End If
End If
Next ctl
Set ctl = Nothing
Dim udt As Control
For Each udt In Me.Controls
If udt.Tag = "Undetermined" Then
If IsNull(udt) Then
MsgBox "You must provide an explanation if the " _
& udt.ControlSource & " field is Undetermined."
Cancel = True
udt.SetFocus
Exit For
End If
End If
Next udt
Set udt = Nothing
End Sub
Thank You.
answers are either, "Yes", "No", or "Undetermined". If the user answers
"Undetermined" I have a text box that appears that requires a comment.
I have code in the form's BeforeUpdate property that checks for (1) the
initial answers and (2) for the comments to be completed in any question with
an "Undetermined" answer. What I want is for the code to pause between the
two to allow the user to complete the missing fields. Help. Here is my code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ctl As Control
Dim blnContinue As Boolean
blnContinue = True
For Each ctl In Me.Controls
If ctl.Tag = "Required" Then
If IsNull(ctl) Then
MsgBox "You must complete the " _
& ctl.ControlSource & " field."
Cancel = True
ctl.SetFocus
Exit For
End If
End If
Next ctl
Set ctl = Nothing
Dim udt As Control
For Each udt In Me.Controls
If udt.Tag = "Undetermined" Then
If IsNull(udt) Then
MsgBox "You must provide an explanation if the " _
& udt.ControlSource & " field is Undetermined."
Cancel = True
udt.SetFocus
Exit For
End If
End If
Next udt
Set udt = Nothing
End Sub
Thank You.