Chapter 19: Advanced Access Form Techniques
683
l (^) The Left, Top, Width, and Height properties: Using these properties, you can con-
trol the position and dimensions of a control on the form.
l (^) The MenuBar, ShortcutMenu, ShortcutMenuBar properties: If you have defined
custom ribbons or shortcut menus, you can use these form properties to dynamically
change the ribbon and shortcut menus as the user works with the application.
l The Custom Ribbon ID: If the current application includes custom ribbons, the ribbon
IDs appear in this property’s drop-down list. Access shows and hides the assigned ribbon
as the form is opened and closed.
The SetProperty function can be used to set the value of any property of an open form or a
property of controls on an open form:
Public Function SetProperty(
ByVal strFormName As String,
ByVal strCtrlName As String,
ByVal strPropName As String,
ByVal strNewValue As Variant) As Boolean
Dim frmName As Form
Dim strMsg As String
Dim strFunction As String
Dim strObjName As String
On Error GoTo HandleError
SetProperty = False
strFunction = “SetProperty”
‘If no control name is passed, must be a form:
If Len(strCtrlName) > 0 Then
‘We fall through to this code if
‘strCtrlName is not an empty string.
‘Assign new control property value:
strObjName = strCtrlName
‘If no form name provided,
‘exit procedure:
If strFormName = ““ Then
Exit Function
End If
Set frmName = Forms(strFormName)
frmName(strCtrlName).Properties( _
strPropName) = strNewValue
SetProperty = True
Else
‘We fall through to this code if
‘strCtrlName is an empty string.
‘Assign new form property value:
strObjName = strFormName
Set frmName = Forms(strFormName)
frmName.Properties(strPropName) = strNewValue
SetProperty = True
End If