J
JohnSmith
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q308312
The above link is to an atricle on how to implement SQL Server Application
roles with and access project. In a nutshell it goes like this:
1. Create an Application role on the SQL Server DB.
2. After you connect with your ADP, fire a bit of code to set the
application role for your session. This will set the users permissions
within the context of the application but will prevent the user from using
third party tools to view the data on the same database.
<Excerpt From Document>
The main complication when you are using application roles in Access
projects is that Access uses three connections to SQL Server to handle
various tasks. Ideally, to apply an application role to the whole project,
you would have to execute sp_setapprole in the context of all three
connections. The objects handled by each connection are as follows:
1. Used for determining which objects appear in the Database window and for
miscellaneous database administrative tasks.
2. Used for opening tables, views, stored procedures, functions, and the
record sources for forms and subreports (but not for the main report
itself).
3. Used for obtaining the record sources for combo boxes, list boxes, and
reports.
Although connections #2 and #3 can be accessed fairly easily, <Not shouting,
just highlighting>THERE IS NO METHOD AVAILABLE FOR EXECUTING THE STORED
PROCEDURE IN THE CONTEXT OF CONNECTION #1. FORTUNATELY, THIS CONNECTION IS
THE LEAST IMPORTANT OF THE THREE AND IS EASILY WORKED AROUND BY CONSTRUCTING
YOUR OWN USER INTERFACE (FOR EXAMPLE, A SWITCHBOARD-TYPE FORM) FOR HANDLING
DATABASE OBJECTS INSTEAD OF RELYING ON THE BUILT-IN DATABASE WINDOW.
<End Excerpt>
So given this, here is my issue:
I have a form that is based on an object in the database. The record source
is set to the name of that object.
Scenario 1 - If I explicitly grant permissions on that object to the user
in the DB (no Application Role) everything works as it should when I log in
via the ADP.
Scenario 2 - If I explicitly grant permissions on that object to the user
in the DB and then set the Application Role (modifying those permissions)
everything works as it should when I log in via the ADP.
Scenario 3 - If I do NOT grant explicit permissions, but depend upon the
Application Role, the form does not find the object when it opens. I get the
following error:
Run-Time error '2850':
The record source '<source_name>' specified on this form or report does
not exist.
I know that I, in fact, have permissions on it because I can reference it
programatically in another area of the ADP. Nearest I can Figure is that
when I use only the applicating role, the form cannot find it because it is
not 'in the database window'. The name of the object is being set somewhere
on the ADP side.
Therin lies my problem: After banging my head for a couple of days on this
I am totally stuck on how to get the form to recognize the existance of the
underlying object. The easy workaround simply is not coming to me.
How do I get the ADP to recognize the objects upon which it has permissions
in the SQL Server DB?
Cheers and thanks,
Ian.
The above link is to an atricle on how to implement SQL Server Application
roles with and access project. In a nutshell it goes like this:
1. Create an Application role on the SQL Server DB.
2. After you connect with your ADP, fire a bit of code to set the
application role for your session. This will set the users permissions
within the context of the application but will prevent the user from using
third party tools to view the data on the same database.
<Excerpt From Document>
The main complication when you are using application roles in Access
projects is that Access uses three connections to SQL Server to handle
various tasks. Ideally, to apply an application role to the whole project,
you would have to execute sp_setapprole in the context of all three
connections. The objects handled by each connection are as follows:
1. Used for determining which objects appear in the Database window and for
miscellaneous database administrative tasks.
2. Used for opening tables, views, stored procedures, functions, and the
record sources for forms and subreports (but not for the main report
itself).
3. Used for obtaining the record sources for combo boxes, list boxes, and
reports.
Although connections #2 and #3 can be accessed fairly easily, <Not shouting,
just highlighting>THERE IS NO METHOD AVAILABLE FOR EXECUTING THE STORED
PROCEDURE IN THE CONTEXT OF CONNECTION #1. FORTUNATELY, THIS CONNECTION IS
THE LEAST IMPORTANT OF THE THREE AND IS EASILY WORKED AROUND BY CONSTRUCTING
YOUR OWN USER INTERFACE (FOR EXAMPLE, A SWITCHBOARD-TYPE FORM) FOR HANDLING
DATABASE OBJECTS INSTEAD OF RELYING ON THE BUILT-IN DATABASE WINDOW.
<End Excerpt>
So given this, here is my issue:
I have a form that is based on an object in the database. The record source
is set to the name of that object.
Scenario 1 - If I explicitly grant permissions on that object to the user
in the DB (no Application Role) everything works as it should when I log in
via the ADP.
Scenario 2 - If I explicitly grant permissions on that object to the user
in the DB and then set the Application Role (modifying those permissions)
everything works as it should when I log in via the ADP.
Scenario 3 - If I do NOT grant explicit permissions, but depend upon the
Application Role, the form does not find the object when it opens. I get the
following error:
Run-Time error '2850':
The record source '<source_name>' specified on this form or report does
not exist.
I know that I, in fact, have permissions on it because I can reference it
programatically in another area of the ADP. Nearest I can Figure is that
when I use only the applicating role, the form cannot find it because it is
not 'in the database window'. The name of the object is being set somewhere
on the ADP side.
Therin lies my problem: After banging my head for a couple of days on this
I am totally stuck on how to get the form to recognize the existance of the
underlying object. The easy workaround simply is not coming to me.
How do I get the ADP to recognize the objects upon which it has permissions
in the SQL Server DB?
Cheers and thanks,
Ian.