|
-
Apr 26th, 2006, 10:11 PM
#1
[FAQ's: OD] How do I bypass my database's autoexec/startup macro?
One of the easiest ways to execute macro code at the startup of an Access database is to use Access' autoexec macro. You can apply security, GUI changes like hiding certain toolbars and menus, showing a startup form, etc. Although, this is also the easiest method to circumvent by pressing down and holding the shift key before you double left click the database in windows explorer. The AllowBypassKey property bypass' the startup properties and the AutoExec macro.
You can turn on and off the Shift Key (AllowBypassKey) behavior during startup by writting VBA code:
AllowBypassKey:
Determines if the SHIFT key can be used to bypass the application load processes such as the running of the autoexec macro or the startup properties. The property's setting doesn't take effect until the next time the database opens. You should make sure the AllowBypassKey property is set to True when debugging an application.
True: Enable the SHIFT key to allow the user to bypass the startup properties and the AutoExec macro.
False: Disable the SHIFT key to prevent the user from bypassing the startup properties and the AutoExec macro.
Access 2003 VBA Code Example:
VB Code:
Public Sub SetBypassProperty()
Const DB_Boolean As Long = 1
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub
Public Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True
Change_Exit:
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Exit
End If
End Function
Source: Access Help File
Last edited by RobDog888; Jun 28th, 2006 at 03:19 AM.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|