Question : Access ADP: Suppress "The SELECT permission was denied on the object database schema 'dbo'" message

I have and ADP 2003/SQL 2005 Application that when logged you are taken to a main form that has tabs. The tabs are subforms. Each subform is from a different table linked to the main table. The main table is the datasource for the main form. I have setup my security so that a user can only view info from the tabs that I give them access to through SQL. This means that when a user opens the form  of which I have denied access to a certain table that is the datasource for one of the tabs (subforms) they get the "The SELECT permission was denied on the object" warning onnce per denied table. Then they can work in the form with thier appropriate permissions. Basically my question is..... Is there a way to suppress these messages?

Answer : Access ADP: Suppress "The SELECT permission was denied on the object database schema 'dbo'" message

Since the author has offered a solution, I think more proper resolution will be PAQ/refund.

However, I also have a suggestion about how this could be implemented, possibly easier.

For those subforms that are bound to the tables where permission may or may not exist, specify their recordsource as empty.

Then, when the time comes to show them, check (in code) if the permission does exist, and if not, hide the subform and show a message instead. Code like this should work:

on error resume next
set o = currentproject.connection
o.execute "select top 1 1 from mytable"
I_Have_No_Permission = False
I_Have_No_Permission = (o.Errors.Count = 1 And o.Errors(0).SQLState = 42000)

subform1.visible = Not I_Have_No_Permission
subform1.form.recordsource = iif(if subform1.visible,"select * from mytable","")

label1.visible = not subform1.visible
label1.caption = "You don't have permission"  ' superimposed on the subform

Random Solutions  
 
programming4us programming4us