Hi All,
I have a form and need to make sure that 5 of those fields have data before the record is saved.
On the form the fields are in the following Tab order:
DATE NOTIFIED, DATE OF INCIDENT, FNAME, LNAME, AGENCY
I have some code on the BeforeUpdate event of the Form which is shown below:
When i test for a value in those columns by hitting the save button(with no data entered), the first field that it detects needs data is Date of Incident. I want it to validate each field based on it's tab position, so it should say DATE OF NOTIFICATION before DATE OF INCIDENT. Maybe I am missing something in my code, or maybe there is a better way to validate these fields. Any Help is appreciated. Thanks in advance.
I have a form and need to make sure that 5 of those fields have data before the record is saved.
On the form the fields are in the following Tab order:
DATE NOTIFIED, DATE OF INCIDENT, FNAME, LNAME, AGENCY
I have some code on the BeforeUpdate event of the Form which is shown below:
When i test for a value in those columns by hitting the save button(with no data entered), the first field that it detects needs data is Date of Incident. I want it to validate each field based on it's tab position, so it should say DATE OF NOTIFICATION before DATE OF INCIDENT. Maybe I am missing something in my code, or maybe there is a better way to validate these fields. Any Help is appreciated. Thanks in advance.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
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 Trim(ctl.Value & "") = "" Then
Msg = "'" & ctl.Name & "' is Required!" & DL & _
"Please enter a value . . ."
Style = vbInformation + vbOKOnly
Title = "Required Data Missing! . . ."
MsgBox Msg, Style, Title
ctl.SetFocus
Cancel = True
Exit For
End If
End If
Next
End Sub
Comment