Hello, I am tiring to write a (more or less) all purpose validation code, what I have so far works except for one thing, if there are multiple controls needing validation and you execute a command with out entering data the focus will move to the next control failing validation and so forth until the last control, were it will finally keep focus until you enter a value, Any insight in to how to keep focus on the control that first fails validation until value is entered is appreciated
Private Sub cmdClose_Enter()
Dim nl As String, ctl As Control
nl = vbNewLine & vbNewLine
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acCheckBox
If Trim(ctl & "") = "" And ctl.Tag = "v" Then
Msg = "Data Required for '" & ctl.Name & "' field!" & nl & _
"Required Data!" & nl & "Please enter the data and try again ... "
Style = vbInformation + vbOKOnly
Title = "Required Data..."
MsgBox Msg, Style, Title
ctl.SetFocus
Cancel = True
End If
Case Else
End Select
Next ctl
End Sub
Private Sub cmdClose_Enter()
Dim nl As String, ctl As Control
nl = vbNewLine & vbNewLine
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acCheckBox
If Trim(ctl & "") = "" And ctl.Tag = "v" Then
Msg = "Data Required for '" & ctl.Name & "' field!" & nl & _
"Required Data!" & nl & "Please enter the data and try again ... "
Style = vbInformation + vbOKOnly
Title = "Required Data..."
MsgBox Msg, Style, Title
ctl.SetFocus
Cancel = True
End If
Case Else
End Select
Next ctl
End Sub