Using VBA to create start up options in Access

G

Guest

What is the VBA code needed to change startup options for a specified user?
I have a database where all the startup options are disabled for all users
except the administrator (CR).

I want to turn these on if the administrator is logged on.
The following code will display the database window:
If strCurrentUser = "CR" Then
DoCmd.SelectObject acTable, , True
End If

What code is needed for the other six startup options?
 
G

Guest

Sorry but I don't think this site answers my question. Perhaps I'm being dense!

The code i have is in a start up form. The user name is checked when the
database opens so the start up conditions can be automatically checked
against the user name
There are 7 options in the startup dialog. I have all 7 switched off by
default & want them on for the administrator only. The options are:
1. Display Database Window (code already done)
2. Display Status Bar
3. Allow Built-In Toolbars
4. Allow Toolbar/Menu Changes
5. Allow Full Menus
6. Allow Default Shortcut Menus
7. Use Access Special Keys

What code would switch each of 2->7 on?
e.g. DoCmd.AllowFullMenus=True ...is no use
What should it be?
Should I use SetProperty? If so, how?

Thanks
 
J

Joseph R. Pottschmidt

Hey Ridders:

What I would suggested that you do, is hide all that anyway and then
create a MDE file of just the application parts (Queries, Forms,
Reports, Macros, Modules), Having the Tables in a separate MDB file.
This way you can have the option of having the customer menus when they
are running the application, but once the application is open, the admin
can open the database window simply by pressing F11.

Then he would be allowed to make changes, test them, and then distribute
a new MDE file to all the users.

The other option is to make use of the CurrentUser() function that is
available in MS Access. This will allow you to setup permissions for
each table, Query, Form, Report, Macro, and module that you have in your
MDB file.

Read up on how to implement a Database MDW file with your current
MDE/MDB file. This way you can have some security with your app, if that
is the reason that you want these options.



-----Original Message-----
From: ridders [mailto:[email protected]]
Posted At: Tuesday, May 01, 2007 3:36 PM
Posted To: microsoft.public.access.modulesdaovba
Conversation: Using VBA to create start up options in Access
Subject: Using VBA to create start up options in Access

What is the VBA code needed to change startup options for a specified
user?
I have a database where all the startup options are disabled for all
users
except the administrator (CR).

I want to turn these on if the administrator is logged on.
The following code will display the database window:
If strCurrentUser = "CR" Then
DoCmd.SelectObject acTable, , True
End If

What code is needed for the other six startup options?
 
A

Alex Dybenko

hi,
I think all these properties in database object, if you run that code:

Dim prp As Property

For Each prp In db.Properties
Debug.Print prp.Name
Next prp

it will give you list of all, and what you are looking for are:

StartUpShowDBWindow
StartUpShowStatusBar
StartUpMenuBar
AllowShortcutMenus
AllowFullMenus
AllowBuiltInToolbars
AllowToolbarChanges
AllowBreakIntoCode
AllowSpecialKeys

so you can just use mentioned page code to set these properties

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
 
S

Scott McDaniel

Sorry but I don't think this site answers my question. Perhaps I'm being dense!

The code at the link supplied by Alex will indeed allow you to change Startup options (the ChangeProperty function will
either change the property, or create it with the value you specify), but as Alex said those options won't be in place
until you close and re-open the database. You cannot, for example, set DisplayDatabaseWindow=True and have the db window
show in the CURRENT session of your db ... however, the next time someone - anyone - starts the db, the database window
will then show up.

If you want them to be turned on for the Admin, then the Admin would have to open the database, then close it, then
reopen it ... or you could provide a separate interface for the Admin (assuming you've split the database, that is).

You can always build different toolbars for different Users/Groups, then turn them on/off based on user login ... this
would give you a lot more control over the interface, and allow you to provde different functionality for different
users. Still, you can't turn the Startup items on/off in the current session of your database ...

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
G

Guest

Hi Alex / scott

Thanks for both of your replies.
Haven't had time to try out what you suggest yet but I must contradict one
thing you both stated.
I have for some months used code "DisplayDatabaseWindow=True" for specified
user only. See my original post.
This code is attached to a hidden form used at startup
It works fine without the user closing & reopening the database.
Other users never see the database window!

So I'm wondering if i use the properties listed by Alex in this hidden form,
will these also work 'on the fly'
 
G

Guest

Alex

Now I really am being dense.
Please can you explain where & how to use your original code idea:
------------------------------------
Dim prp As Property

For Each prp In db.Properties
Debug.Print prp.Name
Next prp

it will give you list of all, and what you are looking for are:

StartUpShowDBWindow
StartUpShowStatusBar
StartUpMenuBar
AllowShortcutMenus
AllowFullMenus
AllowBuiltInToolbars
AllowToolbarChanges
AllowBreakIntoCode
AllowSpecialKeys
 
G

Guest

Alex

Sorry - I don't understand your reply:
here you get properties names (where?)
now you can use code, provided via link, (What code / what link?)
to set these properties, the same way like in link's example (what example?)

I've looked at both of your web addresses but I don't think these are relevant

Can you please assist me further
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top