newbyvba
Technical User
- Feb 22, 2012
- 11
I wanted some code to verify users had entered info in some fields on a form. This code looks perfect but i'm getting an error saying: compile error: next without For... whats wrong please?
Dim Msg As String, Style As Integer, Title As String
Dim DL As String, ctl As Control
DL = vbNewLine & vbNewLine
For Each ctl In Me.Controls
If ctl.Tag = "?" Then
If IsNull(ctl) Then
Msg = "'" & ctl.Name & "' is required and can't " & _
"be left blank!" & DL & _
"Go back and enter some data! . . ."
Style = vbInformation + vbOKOnly
Title = "Missing Required Data Error! . . ."
MsgBox Msg, Style, Title
Cancel = True
ctl.SetFocus
Exit For
End If
Next
Dim Msg As String, Style As Integer, Title As String
Dim DL As String, ctl As Control
DL = vbNewLine & vbNewLine
For Each ctl In Me.Controls
If ctl.Tag = "?" Then
If IsNull(ctl) Then
Msg = "'" & ctl.Name & "' is required and can't " & _
"be left blank!" & DL & _
"Go back and enter some data! . . ."
Style = vbInformation + vbOKOnly
Title = "Missing Required Data Error! . . ."
MsgBox Msg, Style, Title
Cancel = True
ctl.SetFocus
Exit For
End If
Next