Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Startup procedure 1

Status
Not open for further replies.

Zeroanarchy

Technical User
Jun 11, 2001
630
AU
Ok created the following code to run on start up so as it makes all the menus + extra disapear, only problem is I do not know where to put it. lol If I put it in with the startup form none of it will work. Tried making an Autoexec module but of course that is not called on at start up. Can anyone advise me as to where you place code that you want to run before your first form appears. Set by set might help.
Thanks ZeroAnarchy

Private Sub Autoexec()
Dim db As Database
Dim prp As Property
Dim intX As Integer
Set db = CurrentDb

Application.SetOption "Show Hidden Objects", False
Application.SetOption "Show System Objects", False
Application.SetOption "Provide Feedback With Sound", False
Application.SetOption "Show Values Limit", 10000
Application.SetOption "Move After Enter", 1
Application.SetOption "Behavior Entering Field", 0
Application.SetOption "Arrow Key Behavior", 1
Application.SetOption "Show Status Bar", False
Application.SetOption "Default find/replace behavior", 1
DoCmd.OpenForm "Data"
DoCmd.ShowToolbar "Database", acToolbarNo
DoCmd.ShowToolbar "Filter/Sort", acToolbarNo
DoCmd.ShowToolbar "Form Design", acToolbarNo
DoCmd.ShowToolbar "Form View", acToolbarNo
DoCmd.ShowToolbar "Formatting (Datasheet)", acToolbarNo
DoCmd.ShowToolbar "Formatting (Form/Report)", acToolbarNo
DoCmd.ShowToolbar "Macro Design", acToolbarNo
DoCmd.ShowToolbar "Menu Bar", acToolbarNo
DoCmd.ShowToolbar "Print Preview", acToolbarNo
DoCmd.ShowToolbar "Query Datasheet", acToolbarNo
DoCmd.ShowToolbar "Query Design", acToolbarNo
DoCmd.ShowToolbar "Relationship", acToolbarNo
DoCmd.ShowToolbar "Report Design", acToolbarNo
DoCmd.ShowToolbar "Source Code Control", acToolbarNo
DoCmd.ShowToolbar "Table Datasheet", acToolbarNo
DoCmd.ShowToolbar "Table Design", acToolbarNo
DoCmd.ShowToolbar "Toolbox", acToolbarNo
DoCmd.ShowToolbar "Utility 1", acToolbarNo
DoCmd.ShowToolbar "Utility 2", acToolbarNo
DoCmd.ShowToolbar "Web", acToolbarNo
DoCmd.ShowToolbar "Visual Basic", acToolbarNo
Set prp=db.CreateProperty("AllowByPassKey",dbBoolean, False)
Set prp=db.CreateProperty("StartupShowDBWindow",DB_BOOLEAN, False)
Set prp=db.CreateProperty("StartupShowStatusBar", DB_BOOLEAN, False)
Set prp = db.CreateProperty("AllowBuiltinToolbars", DB_BOOLEAN, False)
Set prp = db.CreateProperty("AllowFullMenus", DB_BOOLEAN, False)
Set prp = db.CreateProperty("AllowBreakIntoCode", DB_BOOLEAN, False)
Set prp = db.CreateProperty("AllowSpecialKeys", DB_BOOLEAN, False)

End Sub
 
hi

thank you, Ok great that worked BUT the bypass key i.e. the shift key can still be used and therefore peopel can use it to enable them to get to the design window, is there anyway of stopping this please,,,

Martin
 
Hi!

You need to add the property to the database called AllowBypassKey and set the property to false.

hth Jeff Bridgham
bridgham@purdue.edu
 
haha ok, got that now is there anyway to bring the db window back! lol i haven;t yet done it, but i know that iwll probably lock me out, can i add a button which will bring the db window back

-martin :)
 
here is some code that may be of some use, the idea behind not putting the Shift lock in the startup code is that if you do you will never get back into your program.
Hint: Place a hidden button somewhere in your program that open a new form called say managment options:
place to buttons in this form say activate and deactivate
and on click place the following code:private Sub

Deactivate_Click()
Dim db As Database
Dim prp As Property
Set db = CurrentDb
Set prp = db.CreateProperty("AllowByPassKey", dbBoolean, False)
db.Properties.Append prp
MsgBox "System Lockdown, the shift key has been blocked"
DoCmd.Close
DoCmd.OpenForm "Autoexec", acNormal
End Sub

Activate_Click()
Dim db As Database
Set db = CurrentDb
db.Properties.Delete "AllowByPassKey"
db.Properties.Refresh
MsgBox "System open, the program is currently unlocked"
DoCmd.Close
DoCmd.OpenForm "Autoexec", acNormal
End Sub

Hope this help. The benefit is that you can activate the button when ever you like and also deactivate it when it suits.

Good luck ;-)
 
Martin,

Another option is to use a field on a form with an associated button and have a set ID code to allow the bypass key e.g.
Code:
Lock_Button_Click()

If [Me]![MyField] = 12345 then 

{allow bypass key routine, as described by zero above}

If [Me]![MyField] = 54321 then 

{block bypass key routine, as described by zero above}

else: Exit Sub

You can then run this from a form which launches from a visible button. Only the database administrator should have permissions on the form (assuming your db is secured).

This has the advantage of making it much easier for anyone working on your db after you (what if you leave your current job?) to unlock it.

hth Robbo ;-)
 
Hi Martin!

Always have an extra button on your menu form that is only visible and enabled if the person logged in is the administrator. This button should lead you to a form that will allow you to bypass security.

hth Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top