I have a form based on a table where some fields are required to be filled by the user. 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 shows the field name (by its label name) that needs to be filled and also an instruction that if the user does not wish to complete and save the record to press escape. I have looked through previous similar questions on this and other forums 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 update but the default Microsoft message is either precedent or my code is wrong or in the wrong place:
I have tried the following code in the form's before update but the default Microsoft message is either precedent or my code is wrong or in the wrong place:
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 & "") = "" Then
Msg = "'" & ctl.Name & "' is Required!" & DL & _
"Please enter a [URL="http://www.tek-tips.com/viewthread.cfm?qid=1596297&page=1#"]value[/URL] or hit Esc to abort the record . . ."
Style = vbInformation + vbOKOnly
Title = "Required [URL="http://www.tek-tips.com/viewthread.cfm?qid=1596297&page=1#"]Data[/URL] Missing! . . ."
MsgBox Msg, Style, Title
ctl.txtIssueDate.SetFocus
Cancel = True
Exit For
End If
End If
Next
End Sub [code]
Is there another way of achieving what I am trying to do or can someone please point me in the right direction?