Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Handling

Status
Not open for further replies.

EscapeUK

Programmer
Jul 7, 2000
438
GB
I would like to display a nice error message when and error occurs, like an ODBC connection not being found. I would the like the code not to bomb out

Any ideas
 
You need to setup handling something like the following.
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 2105 Then
MsgBox "You have entered an asset that already exists in the database!", vbInformation
Response = 0
Exit Sub
ElseIf DataErr = 3022 Then
MsgBox "You have entered an asset that already exists in the database!", vbInformation
Response = 0
Exit Sub
ElseIf DataErr = 3314 Then
MsgBox "You need to enter in a local and global asset number!", vbInformation
Response = 0
Exit Sub
ElseIf DataErr = 3101 Then
MsgBox "You have not entered a valid asset hierarchy, location hierarchy or manufacturer details!", vbInformation
Response = 0
Exit Sub
ElseIf DataErr = 3201 Then
MsgBox "You have not entered valid manufacturer details!", vbInformation
Response = 0
Exit Sub
End If
End Sub

In these, the error is intercepted & a 'friendly' message is given, depending on the error code produced. You can get these error codes by searching for error codes in the access help. Within here it has a couple of functions, which create tables containing the error codes....


Hope this helps James Goodman
j.goodman00@btinternet.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top