Swapping Startup properties based on user

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to change the startup properties based on the user logged in. If
it's the Admin user logging in, the user gets access to everything. If it's
anyone else, I want access to none of the extra features. The code below is
in the 'OnCurrent' event of a form that is opened as soon as the database is
opened/started.

It does exactly what I want, but only after the second log in. For example,
I have all the startup properties checked off initially per the Startup menu
option. I login as Admin once, the database opens and everything is still
not enabled. I close Access and thus the db too, I reopen it again, I login
as Admin again and this time everything is enabled.

If I login as another user next, everything is enabled (but shouldn't be for
this user), I close everything, reopen and then relogin as that other user
again and this time everything is disabled (as it should be).

Is this a timing issue or something? Any help would be greatly appreciated!
Here is the code:

Dim dbs As Object
Set dbs = CurrentDb

If CurrentUser() = "Admin" Then
dbs.Properties("StartupShowDBWindow") = True
dbs.Properties("AllowBuiltinToolbars") = True
dbs.Properties("AllowFullMenus") = True
dbs.Properties("AllowBreakIntoCode") = True
dbs.Properties("AllowSpecialKeys") = True
dbs.Properties("AllowBypassKey") = True
Else
dbs.Properties("StartupShowDBWindow") = False
dbs.Properties("AllowBuiltinToolbars") = False
dbs.Properties("AllowFullMenus") = False
dbs.Properties("AllowBreakIntoCode") = False
dbs.Properties("AllowSpecialKeys") = False
dbs.Properties("AllowBypassKey") = False
End If
 
cindyn wrote:

(snip)
I am trying to change the startup properties based on the user logged in.
It does exactly what I want, but only after the second log in.

This is as expected. The startup properties are actioned, the moment
that the database starts. This is before any of your code has run. If
your code changes those properties, the changes will not take effect
until the next time that the database starts - as you have found.
HTH,
TC
 
Back
Top