This differs from the Jet/DAO databases properties.
Procedure Name | Type | Description |
(Declarations) | Declarations | Declarations and private variables for the modCurrentProject module. |
IsProjectADP | Procedure | Determine if the current project is an ADP. |
IsProjectMDB | Procedure | Determine if the current project is a Jet MDB or ACCDB database. |
ProjectPropertyExists | Procedure | Does this Access database property exist? |
ProjectPropertyGet | Procedure | Get the value of a database property. |
ProjectPropertySet | Procedure | Set a database property value. |
ProjectPropertyCreate | Procedure | Create a new database property. |
ADP_AllowBypassKey | Procedure | Set an ADP's AllowBypassKey property. If it's set to False, users can't hold the shift key down when the database loads to prevent the startup routines from running. For Jet databases, use the Database_AllowBypassKey function in module modJetDatabase. |
' Example of modCurrentProject ' ' To use this example: ' 1. Create a new form. ' 2. Create the following command buttons, and set their "On Click" event to : ' cmdDBPropExists ' cmdGetDBPropVal ' cmdCreateDBProp ' cmdSetDBPropVal ' cmdBypassKey ' 3. Paste the entire contents of this module into the new form's module. ' 4. Paste the entire contents of this module into the new form's module. Private Sub cmdBypassKey_Click() ' Sets an ADP's AllowBypassKey property. If it's set to False, users can't hold the shift key down when the database loads to prevent the startup routines from running. ' For Jet databases, use the Database_AllowBypassKey function in module modJetDatabase. Dim Response As VbMsgBoxResult If IsProjectADP Then Response = MsgBox("Allow the uer to hold the Shift key to bypass startup routines in the current ADP?", vbYesNoCancel) Select Case Response Case vbYes If ADP_AllowBypassKey(True) Then MsgBox "AllowBypassKey set to True." End If Case vbNo If ADP_AllowBypassKey(False) Then MsgBox "AllowBypassKey set to False." End If Case vbCancel MsgBox "No change made to AllowBypassKey" End Select Else MsgBox "ADP_AllowBypassKey is only for ADPs. For Jet databases, use the Database_AllowBypassKey function in module modJetDatabase." End If End Sub Private Sub cmdDBPropExists_Click() ' See if a database property name exists Dim strProperty As String strProperty = InputBox("Enter property name to test") If strProperty <> "" Then If ProjectPropertyExists(strProperty) Then MsgBox "Property " & strProperty & " exists" Else MsgBox "Property " & strProperty & " does not exist" End If End If End Sub Private Sub cmdGetDBPropVal_Click() ' Retrieve a database property value Dim strProperty As String Dim varValue As Variant strProperty = InputBox("Enter property name to test") If strProperty <> "" Then If ProjectPropertyGet(strProperty, varValue) Then MsgBox "The value of Property " & strProperty & " is: " & varValue Else MsgBox "Property " & strProperty & " does not exist" End If End If End Sub Private Sub cmdCreateDBProp_Click() ' Create a database property and assign a value to it ' This example only sets a property of text type (dbText) but other data types can also be created. Dim strProperty As String Dim strValue As String strProperty = InputBox("Enter a new property name to create") If strProperty <> "" Then If ProjectPropertyExists(strProperty) Then MsgBox "Property " & strProperty & " already exists" Else strValue = InputBox("Enter the text value to assign to this property") If ProjectPropertySet(strProperty, strValue) Then MsgBox "Property " & strProperty & " was created and assigned to " & strValue Else MsgBox "Property " & strProperty & " was not created" End If End If End If End Sub Private Sub cmdSetDBPropVal_Click() ' Set a database property value Dim strProperty As String Dim varValue As String strProperty = InputBox("Enter a property name to change") If strProperty <> "" Then If ProjectPropertyExists(strProperty) Then varValue = InputBox("Enter the new value for this property") If ProjectPropertySet(strProperty, varValue) Then MsgBox "Property " & strProperty & " was assigned" Else MsgBox "Failed: property " & strProperty & " was not assigned" End If Else MsgBox "Property " & strProperty & " does not exist" End If End If End Sub Private Sub Form_Load() Const cintLeft As Integer = 100 Const cintWidth As Integer = 3000 Const cintHeight As Integer = 400 ' Setup controls With Me.cmdDBPropExists .Top = 100 .Left = cintLeft .Width = cintWidth .Height = cintHeight .Caption = "Property Exists" End With With Me.cmdGetDBPropVal .Top = 600 .Left = cintLeft .Width = cintWidth .Height = cintHeight .Caption = "Property Value" End With With Me.cmdCreateDBProp .Top = 1100 .Left = cintLeft .Width = cintWidth .Height = cintHeight .Caption = "Create Property" End With With Me.cmdSetDBPropVal .Top = 1600 .Left = cintLeft .Width = cintWidth .Height = cintHeight .Caption = "Set Property" End With With Me.cmdBypassKey .Top = 2100 .Left = cintLeft .Width = cintWidth .Height = cintHeight .Caption = "Bypass Key (ADP Only)" End With End Sub
The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.
Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!
Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!
"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."
Van T. Dinh, Microsoft MVP