Catch a null primary key error

BobJones

Registered User.
Local time
Today, 05:45
Joined
Jun 13, 2006
Messages
42
Hey guys,

Anyone know how to go about catching the "Index or primary key cannot contain a Null value." message box and perhaps showing a custom message instead?

Thanks in advance,
Bob
 
Put this code in the Before Update envent of your form;

Code:
If IsNull(Me.DataID) Or Me.DataID = "" Then
    MsgBox "You have not entered a Data ID", vbInformation, "No Primary Key"
    Cancel = True
    Me.DataID.SetFocus
End If

DataID is the primary key, set to Number /Required.
 
thx very much for your help, it worked great.
 

Users who are viewing this thread

Back
Top Bottom