VB Code:
  1. On Error Goto ErrTrap
  2. 'your database code
  3. Exit Sub
  4. ErrTrap:
  5. Msgbox "An Error has occurred.  That error is: " & Err.Number & " " & Err.Description
  6. End Sub