Hello llyal,
I have two bits of code for you to control the applications environment. Please note that this is for MSAccess 95 and later versions of access
have other properties that you can/must include.
The first function sets up MSAccess Properties.......
Public Function fSetStartupProperties() As Boolean
'**********************************************
'Purpose ' Sets MSAcess environment.
'Author ' DataSys Software Technologies Ltd.
'In ' Nothing
'Returns ' True if successful else false.
'**********************************************
On Error GoTo Err_fSetStartupProperties
fSetStartupProperties = True
If CurrentUser() = "Support" Then
fChangeProperty "StartupShowDBWindow", dbBoolean, True
fChangeProperty "StartupShowStatusBar", dbBoolean, True
fChangeProperty "AllowBuiltinToolbars", dbBoolean, True
fChangeProperty "AllowFullMenus", dbBoolean, True
fChangeProperty "AllowBreakIntoCode", dbBoolean, True
fChangeProperty "AllowSpecialKeys", dbBoolean, True
fChangeProperty "AllowBypassKey", dbBoolean, True
Else 'everyone else
fChangeProperty "StartupShowDBWindow", dbBoolean, False
fChangeProperty "StartupShowStatusBar", dbBoolean, True
fChangeProperty "AllowBuiltinToolbars", dbBoolean, False
fChangeProperty "AllowFullMenus", dbBoolean, False
fChangeProperty "AllowBreakIntoCode", dbBoolean, False
fChangeProperty "AllowSpecialKeys", dbBoolean, False
fChangeProperty "AllowBypassKey", dbBoolean, False
End If
Exit_fSetStartupProperties:
On Error Resume Next
Exit Function
Err_fSetStartupProperties:
fSetStartupProperties = False
MsgBox Err.Description
Resume Exit_fSetStartupProperties
End Function
This next function loops through a table called 'tblSysOption' I have created that contains all the properties available ie: confirm action queries? show status bar etc, etc
Table layout (NB:Field names in first Line) with example data as follows: (Note: You will need to put this into something like notepad as you can't see the layout correctly as there is no provision for including tabs in this mail!!!)
OptionText StringArgument Setting AppSetting SettingType Tab Status DateRec
Status Bar Show Status Bar True chk View Tab L 14/05/1999
Startup Dialog Box Show Startup Dialog Box True chk View Tab L 14/05/1999
Hidden Objects Show Hidden Objects True False chk View Tab L 14/05/1999
System Objects Show System Objects False chk View Tab L 14/05/1999
The field 'Setting' is the original setting as defined by MSAccess. The field 'AppSetting' is the changes to the environment that I want for MSAccess. On exiting your application you should look
at setting the options to their original values.
Public Function fSetOptions() As Boolean
'*******************************************************
'Purpose ' Sets the applications start-up properties.
'Author ' DataSys Software Technologies Ltd.
'In ' Nothing
'Returns ' True if successful else false
'*******************************************************
On Error GoTo Err_fSetOptions
fSetOptions = True
Dim Db As DATABASE
Dim rst As Recordset
Set Db = CurrentDb
Set rst = Db.OpenRecordset("tblSysOption", dbOpenSnapshot)
rst.MoveFirst
Do Until rst.EOF
'if an Application defined setting exists then use it else use the default settings.
If Not fIsNothing(rst!AppSetting) Then
Application.SetOption rst!StringArgument, rst!AppSetting
Else
Application.SetOption rst!StringArgument, rst!Setting
End If
rst.MoveNext
Loop
Exit_fSetOptions:
On Error Resume Next
rst.Close
Db.Close
Exit Function
Err_fSetOptions:
fSetOptions = False
Msgbox Err.Description
Resume Exit_fSetOptions
End Function
[This message has been edited by Warren Van Duesbury (edited 04-03-2001).]