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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error messages 2

Status
Not open for further replies.

djam

Technical User
Nov 15, 2002
223
0
0
CA
how would I stop a error message from displaying? I'm using linked tables from a mysql database and it triggers a error message if a field is empty. I would like to stop the mysql error message and replace it with my own error messsage. How would I know which error that is beening triggered? Depending on the error, i would like to handle it differently.


thanks
 
[tt]
Hi:

What is the exact error message: "...." ? [glasses] Gus Brunston, using Access2000 Intermediate skills.
 
You can trap errors using:

On Error Goto errHandlerRoutine

Then, in your error handler, you can use the Err object to identify diferent errors, as in

MsgBox "Error number " & Err.Number & ", Error Desc: " & Err.Description

or like

With Err
Select Case .Number
Case 1
Do stuff
Case 2
Do other stuff
Case Else
Don't do stff
End Select
End With


you get the idea.



 
Private Sub Form_Error(DataErr As Integer, response As
Integer)
MsgBox "This is a required field"
End Sub

this is what I have right now,

but the message I get is "ODBC--insert on a linked table 'CONTACT_TABLE' failed"

this message means that I require a entry in a required field.

but I would like to stop this message from happening and only run my error message, because the other error message makes no sense to the users
 
[tt]
Hi:

I think you need the error number to trap it.

I've got a table of 1800 errors and their numbers. I tried to find the error number for the following, but I can't find one that matches:

ODBC--insert on a linked table 'CONTACT_TABLE' failed

What version of Access are you using? [glasses] Gus Brunston, using Access2000 Intermediate skills.
 
[tt]
Hi again

Found it. Your error number is 3155.

You can trap it like this:
...
If Err.Number = 3155 Then
MsgBox "This is a required field"
Exit Sub
Else
MsgBox Err.Description
End If
...

Hope this helps.
[glasses] Gus Brunston, using Access2000 Intermediate skills.
 
I'm using Access 2000, I tried the code, but the other error message stay displays after I put my own message. Is there a way to stop this? Better yet, is there a way to do some checking before it does the insert? I've created my own navigation buttons so this problem only happens when I make a entry and keep tabbing through the fields and trigger the insert.

thanks
 
I can set the Cycle property to current record so that the tabing won't make a insert. But there is still a problem bc if this is a subform and if I take the focus outside the subform, it will still trigger a insert and the error message that I want to suppress will still trigger...
 
[tt]
Why don't you post the code you're using in the control where you want to trap the error? [glasses] Gus Brunston, using Access2000 Intermediate skills.
 
The error number is 0

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If Err.number = 0 Then
MsgBox "Please fill in required fields"
Else
MsgBox Err.DESCRIPTION
End If
End Sub

thanks "so many events, so little time"
 
Hi

You need to set the RESPONSE to tell Access not to display its own error message

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Response = acDataErrContinue
If Err.number = 0 Then
MsgBox "Please fill in required fields"
Else
MsgBox Err.DESCRIPTION
End If
End Sub

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top