Access options settings in code?

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

Guest

Is there a way to set some of the Access user settings (Tools/Options
settings) in application code so they are automatically set a certain way
when the user opens the application?
 
I'd be interested in programatically setting the following things in
Tools/Options:

General tab - Use four-digit year formatting (This database, All databases)
Edit/Find tab - Confirm options (Record changes, Document deletions, &
Action queries)
Keyboard tab - Behavior entering field (Select entire field, Go to start of
field, & Go to end of field)

ctdak
 
First things First.

Create a module (name it as you like) and include a function called Startup
as follows in my sample code:

Option Compare Database
Public Function Startup()
This function changes the startutp options of MS-Access
'Created by Wally Pons (c) 2004
'Modified on 11-July-2005 @ 9:08 pm E.S.T.

'Cuts the confirm question on action queries
Application.SetOption "Confirm Record Changes", False
Application.SetOption "Confirm Action Queries", False

'Hides forms on the taskbar
Application.SetOption "ShowWindowsInTaskbar", False

'Sets the 4 digits for years <- This is what you wanted
Application.SetOption "Four-Digit Year Formatting", True

'Fix margins for reports as 0.25 for all
Application.SetOption "Left Margin", 0.25
Application.SetOption "Right Margin", 0.25
Application.SetOption "Top Margin", 0.25
Application.SetOption "Bottom Margin", 0.25

'Allows combo boxes to show 32,700 records (32,767 is the limit, you may use
it)
Application.SetOption "Show Values Limit", 32700

'Hides hidden objects (in case somebody forgot to put it back the way it was
before)
Application.SetOption "Show Hidden Objects", False

'Field selection behavior
'0 = Entire Field, 1 = Start of Field, 2 = End of Field
Application.SetOption "Behavior Entering Field", 0

'Enables Font switching
Application.SetOption "Enable Font Switching", True

'Substitution font
Application.SetOption "Substitute Font Name", "Arial"

'The name of the font you always want to use
Application.SetOption "Default Font Name", "Tahoma"

End Function


Then, create a macro called AutoExec and insert into it an action
called RunCode and way below, use the function name StartUp()

This is the best to work it, good luck!!!

WP
 
Wally,
Thanks very much for the detail. It looks pretty straightforward. I'll
build this into my code. Thanks again for the help.
ctdak
 
Wally,

I have implemented your suggested Application.SetOption statements upon
startup. Now I have a few related questions:

1) Am I right that the Startup options can not be set this way because the
application has already opened and started before the code is executed?

2) Is this also true for the Advanced tab record locking options?

3) I notice that Application.References. … is available. Can this be used
to make sure certain reference libraries are loaded, such as MS DAO 3.6
Object Library for instance? If so, how does this work?

ctdak
 
Sorry, it took me a while to come back due a tight work schedule and family
related issues, but please find my responses below your questions.

Regards,

Wally Pons


ctdak said:
Wally,

I have implemented your suggested Application.SetOption statements upon
startup. Now I have a few related questions:

1) Am I right that the Startup options can not be set this way because the
application has already opened and started before the code is executed?
A: That is why you have to make a macro called AutoExec and have it call
your function, otherwise it won't do it at startup time.

2) Is this also true for the Advanced tab record locking options?

A: Yes, any options within the MS Access options and probably a few other
options that don't show on that form.
3) I notice that Application.References. … is available. Can this be used
to make sure certain reference libraries are loaded, such as MS DAO 3.6
Object Library for instance? If so, how does this work?


A: Interesting question, I haven't tried cause I only use either native
MS Access files or a system DSN to MS SQL, but give it a shot yourself and
please, post your experience to the rest of us.
 
Back
Top