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

Suppressing a certain error message

Status
Not open for further replies.

MarkWaddington

Programmer
Aug 19, 2002
64
0
0
GB
Is there any way I can suppress the following error when opening forms?

"There was an error executing this command."

Its error number is "0" and it only happens when a read-only user is logged in and tries to access a form he/she shouldn't be accessing.

Any clues as to how I can stop it? Or change what it says?

Thanks in advance.
 
The best option is not to have the users able to see or click things they don't have any privileges to. If specific forms and queries aren't needed by the user, I'd delete them from their front end. I'm not sure what kind of error-trapping you have at this point, but I'd recommend this finding out what the error number is first. I've never heard of an error number of zero.

Public Sub Form_Load
On Error Goto LoadError


Exit Sub
LoadError:
Debug.print err.number & " " & err.description
End Sub
Then when you find the error number you can then trap for that specific error.
'Then once you find the error number (i just put 3069), then run this sort of code.

Public Sub Form_Load
On Error Goto LoadError


Exit Sub
LoadError:
If Err.Number = 3069
MsgBox "You do not have access to this form",vbInformation
Docmd.Close "yourform"
End If
End Sub

 
I used the following error trapping method:

On Error Goto ErrorHandler


//CODE HERE

ErrorHandler

MsgBox Err.Number


The error number came back as "0". I find it unsettling you have never had it before!

I'm sure there must be an easier way than having to systematically delete switchboard items off my staff's front end according to what user privileges they have?
 
Are you putting an Exit Sub before the error handler? Otherwise you're going to get an error message of 0.
 
Omega36 is right,

you need "Exit sub"
on the line above Error Handler

Transcend
[noevil]
 
Thanks for the replies.

I already had the Exit Sub, what it was was that the switchboard item ran a macro, the macro was: open form, go to new record. But because the user was read only they couldn't go to a new record. So a generic error occurred.

It's working ok now.

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top