Pause between lines of code

G

Guest

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.
 
G

Guest

I don't think there is a way to do that. What you have looks good. Be
careful checking control values for Null. Moreoften, they are a zero length
string (= "").

I did just think of a trick that may (or not) work. How about if you have a
module level variable that the code below could set (See Where I Put It) and
in the After Update event of your controls, if the variable is set to a
value, say True, then reexecute the Before Update event?

Dim blnRetry As Boolean

In the After Update of the controls:

If blnRetry Then
Call Form_BeforeUpdate
End If

What I am not sure of is how this would affect the sequence of events overall
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top