VBA/Excel/Access/Word/Access/Database Properties
Содержание
Changing Options
<source lang="vb">
Public Sub setOptions()
With Application .SetOption "show status bar", False .SetOption "show startup dialog box", False End With
End Sub
</source>
Database properties: AllowFullMenus, Allowtoolbarchanges
<source lang="vb">
Public Sub startupProperties()
Dim myDatabase As Object Set myDatabase = CurrentDb myDatabase.Properties("AllowFullMenus") = False myDatabase.Properties("Allowtoolbarchanges") = False
End Sub
</source>
Enumerate the properties of current database
<source lang="vb">
Sub EnumDBProperties()
Dim pty As Property Dim strTemp As String On Error Resume Next For Each pty In CurrentDb.Properties strTemp = pty.Name & ": " strTemp = strTemp & pty.Value Debug.Print strTemp Next
End Sub
</source>
reset any values you set
<source lang="vb">
Public Sub startupProperties1()
Dim myDatabase As Object Set myDatabase = CurrentDb With myDatabase .Properties.Delete "AllowFullMenus" .Properties.Delete "AllowToolBarChanges" End With Application.RefreshTitleBar
End Sub
</source>
Set new property to database
<source lang="vb">
Sub KeepEmOut()
Dim db As Database Dim pty As Property On Error GoTo KeepEmOut_Err Set db = CurrentDb db.Properties("AllowBypassKey").Value = False
KeepEmOut_Exit:
Exit Sub
KeepEmOut_Err:
If Err.Number = 3270 Then Set pty = db.CreateProperty("AllowBypassKey", dbBoolean, False) db.Properties.Append pty Else Debug.Print Err.Description Resume KeepEmOut_Exit End If
End Sub
</source>
Sub KeepEmOut()
<source lang="vb"> Dim db As Database Dim pty As Property On Error GoTo KeepEmOut_Err Set db = CurrentDb db.Properties("AllowBypassKey").Value = False
KeepEmOut_Exit:
Exit Sub
KeepEmOut_Err:
If Err.Number = 3270 Then "Error code for "Property not found"... "so we"ll create it ourselves Set pty = db.CreateProperty("AllowBypassKey", dbBoolean, False) db.Properties.Append pty Else MsgBox Err.Description Resume KeepEmOut_Exit End If
End Sub
</source>