Custom Errors

  • Thread starter Thread starter the1andonlyjuic
  • Start date Start date
T

the1andonlyjuic

Guest
Making a database for when employees pick up incentive items at multipule location (we have barcoded badges and the barcode is scanned+recorded into the database and their information is diplayed.)

I was wondering how i can customize error alerts. More specifically, the Primary key error.
primarykey.jpg


The button listed at the bottom of the sheet called "Add New" is where i need my custom error message to occur. The text in the module is as follows:
Private Sub New_Entry_Command_Click()
On Error GoTo Err_New_Entry_Command_Click

DoCmd.GoToRecord , , acNewRec
Badge.SetFocus

Exit_New_Entry_Command_Click:
Exit Sub

Err_New_Entry_Command_Click:
MsgBox Err.Description
Resume Exit_New_Entry_Command_Click
End Sub


Since i'm having n00b users, i want to display something like "This person has been entered already, please replace user." . . . just kidding... I would love to do something like that but my boss wouldn't hahaha :p .

What i need for it to read is a list of instructions as to why they would get a primary key error. Something to the effect of:
title: **Primary Key Error**
Msg: You have received this error due to one of the following:
-Employee has picked items from a different location.
-Someone has picked up the item for the employee.
-Employee is involved in a group pick up.
To clear out employee's information, close this message box and then hit "Esc" (escape on your key board).

any ideas?? Thanks a million.
 
error trapping.

If you change this line of code:

MsgBox Err.Description

to:

MsgBox "Error Description " & Err.Description & " Error Number " & Err.number

Now the alert box should also display the error number. You can then write some code to trap this error number, then make your program perform a particular action for whichever Error numbers it detects.
 
Thanks... i figured it out with your help >:-)
 

Users who are viewing this thread

Back
Top Bottom