newbyvba
Technical User
- Feb 22, 2012
- 11
I've put a * in the fields that I want filled in. I've put this code and nothing validates... any ideas? its like there's no validation on there at all!!
Private Sub Form_BeforeUpdate(Cancel As Integer)
' check field for * in tag and check if text entered and provide error
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 ctl.Value = Null Or ctl.Value = "" Then
Msg = "'" & ctl.Name & "' is required and can't " & _
"be left blank!" & DL & _
"please 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
End If
Next
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
' check field for * in tag and check if text entered and provide error
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 ctl.Value = Null Or ctl.Value = "" Then
Msg = "'" & ctl.Name & "' is required and can't " & _
"be left blank!" & DL & _
"please 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
End If
Next
End Sub