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

Error 2603, better handling method required 1

Status
Not open for further replies.

trxnme

Technical User
Jan 12, 2004
7
GB
Hello All

I've got a problem with a database I'm working on. Certain users are not allowed to open some forms, when I test this I get the 2603 error message and the option to end or debug the code. Now I don't want the users to have the option to debug the code, they might do something silly, like try to 'fix' the problem.

I've read the FAQ 702-1595 and tried the fix it suggests, this just changes standard error message to what ever I type in, "Do NOT press 'DeBug' " will just fertilise the user's curiosity.... :) So, what else do I need to do to handle this error properly?

Thanks for reading this

Ian
 
Hi trxnme,

If you trap the error in your code there shouldn't be any system-generated message displayed at all, for example ..

:
:
On Error goto Trap
Docmd.OpenForm etc...
' Continue with normal code here
:
:

Exit Sub
NotAllowed:
MsgBox "You are Not allowed to do this"
' Rest of code when user not allowed
:
:

Exit Sub
Trap:
If Err.Number <> 2603 Then
On Error GoTo 0
Resume
Else
On Error GoTo 0
Resume NotAllowed
End If

End Sub

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
Tony

Thanks, but this is the code I've got in place, after reading the FAQ. I've also tried a Select Case variety of the trap as well, bth varieties result in the option to end or debug the code.

Private Sub RejFollowUpBtn_Click()
On Error GoTo ErrHandler

DoCmd.OpenForm &quot;FollowUpDataEntryFrm&quot;, acNormal

ExitSub:
Exit Sub

ErrHandler:
If Err.Number = 2603 Then
MsgBox &quot;You do not have access to this area of the database&quot;, vbOKOnly
Resume ExitSub
Else
MsgBox Err.Description
Resume ExitSub
End If

End Sub


The last time I had this problem was with SendObject, with that it's a fault in Access VBA. I don't see how this can be the same though.

Thanks

Ian
 
Hi trxnme,

Sorry, I should have read the FAQ first. [blush]

I don't see anything obviously wrong with your code. Is it actually running? have you tried setting a breakpoint on it?

It is possible, if you have trapped an earlier error and not Resumed, that you are in error handling mode already and the trap you think you have set is not actually invoked. Can't readily think of anything else.

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
Perhaps I'm not understanding the problem, but this may help.

In any module, go to Tools -> Options. Click on the general tab. Under the Error Trapping heading, if Break on All Errors is selected, then any error handling you've built into your program will be ignored.

This is actually a good thing while you're in development, as you'll likely want to know when errors are occuring. Eventually you'll need to test your error handling though; to do this just select Break on Unhandled Errors instead of Break on All Errors.
 
Fizban

Doh!!!!!! You sanity saver you. It was the break on all erros option..!! I was going daft trying to work out the error in the code.

Doesn't explain why some errors were handled though.... Still problem sorted, mystery solved.

Thank You
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top