I can't get this to work. I'm not a programmer, so hopefully it's
something I'm doing that's just dumb and simple to fix, but even
after reading all the posts and everything I can find in Access Help,
I can't figure out what it is. Here's my code:
* * * * *
Dim wrkspc As Workspace
Dim db As Database
' Create new Workspace object dbTemp, user Adminuser, password
Ker22mit ' (user and password exist in security settings as a member
of the Admins group
' with full permissions)
Set wrkspc = CreateWorkspace("dbTemp", "adminuser", "Ker22mit")
With wrkspc
Set db = wrkspc.OpenDatabase("C:\FCM-C\FCM.mdb")
[Do function]
End with
* * * * *
This code runs with no errors until it gets to the function. If I'm
originally logged on as a regular user without the necessary
permissions, it returns a "you don't have the right permissions"
error. It's as though I'm still in the default workspace as
originally logged in. What am I missing?
_____________________________
Rick Brandt said:
Carol Giannini wrote:
Is it possible, for the purposes of one function that requires
administrative permissions, to reset the current user to Admin,
execute the function, and then require the user to log in again?
Many thanks in advance -- I don't post much but read a lot and the
help on this forum is phenomenal.
Not exactly, but you can open a new Workspace object and then
within that Workspace you can open another Database object using a
different user's credentials.
Dim ws As Workspace
Set ws = CreateWorkspace("MyWorkspace", "UserName", "Password")
ws.OpenDatabase "path to file"
....
You could prompt for the password so that only a user who knew it
could run the function, but you would not have to "log back in" to
revert back to the original user. Once the workspace object went
out of focus at the end of the fucntion all activities would revert
back to the original user.