Null field friendly error message

  • Thread starter Thread starter Jake F
  • Start date Start date
J

Jake F

I'm touching up a database and want to avoid as many automated error messages
as i can find. One I'm having is a primary key cannot be null error. Where
do I go to replace that with something most users will understand?
 
Use the Error event of the form.

Alternatively, use the BeforeUpdate event of the form (not controls) to test
for null before the error occurs.
 
On Thu, 16 Oct 2008 07:10:01 -0700, Jake F

Have you tried the Form_Error event?

-Tom.
Microsoft Access MVP
 
At it's simplest, you can use the Form_Error event to trap this and other
record-level errors. Something like this:

Private Sub Form_Error(DataErr As Integer, Response As Integer)

If DataErr = 3058 Then
MsgBox "your message"
Response = acDataErrContinue
Else
'msgbox DataErr
Response = acDataErrDisplay
End If

End Sub

3058 is the error number for the null primary key. The "Else" section will
let any other error display the normal system error message. If you want to
know the number for another error, just un-comment the msgbox and you'll get
the error number. Add any additional errors as an ElseIf.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
Back
Top