My form is based on a table where fields are required to be filled. If the user moves on to another record the default MS error message box is shown. What I would like is a friendlier message box that showed the field name that needs to be filled and also an instruction that is the user does not wish to complete the record to press escape. I have looked through previous similar questions but non seem to be exactly what I am looking for. Any advice on how I can over write the default error message for a required field and put in my own or alternative modifiy MS's default message?
I have tried the following code in the form's before updae but I get a compile error on ctl.Name:
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 & "") = "" Then
Msg = "'" & ctl.Name & "' is Required!" & DL & _
"Please enter a value or hit Esc to abort the record . . ."
Style = vbInformation + vbOKOnly
Title = "Required Data Missing! . . ."
MsgBox Msg, Style, Title
ctl.Name.SetFocus
Cancel = True
Exit For
End If
End If
Next
End Sub
I have tried the following code in the form's before updae but I get a compile error on ctl.Name:
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 & "") = "" Then
Msg = "'" & ctl.Name & "' is Required!" & DL & _
"Please enter a value or hit Esc to abort the record . . ."
Style = vbInformation + vbOKOnly
Title = "Required Data Missing! . . ."
MsgBox Msg, Style, Title
ctl.Name.SetFocus
Cancel = True
Exit For
End If
End If
Next
End Sub