OhGorgeous1
08-14-2009, 12:47 AM
Hi all
I have the found the following code that should hide all controls on a form but it doesn't seem to be working can anyone please help on this.
Modules -
Function EnableDisableControls(strForm As String, intSection As Integer, fEnable As Boolean) As Boolean
' Comments : Enables or disables all controls in the specified section of the specified form
' Parameters: strForm - name of a currently open form
' intSection - number of the section to enable/disable controls in
' fEnable - True to enable controls, False to disable
' Returns : True if successful, False otherwise
'
Dim frmIn As Form
Dim ctlTmp As Control
On Error GoTo err_EnableDisableControls
Set frmIn = Forms(strForm)
For Each ctlTmp In frmIn.Controls
If ctlTmp.Section = intSection Then
On Error Resume Next
ctlTmp.Enabled = fEnable
On Error GoTo err_EnableDisableControls
End If
Next ctlTmp
EnableDisableControls = True
exit_EnableDisableControls:
Exit Function
err_EnableDisableControls:
EnableDisableControls = False
Resume exit_EnableDisableControls
End Function
On each form -
Sub DisableControls()
'Disable all controls in the detail section of the form named '????'
Dim bOK As Boolean
bOK = EnableDisableControls("CentralFunctions", 0, False)
End Sub
I will be most grateful for any help anyone can give.
Niki
I have the found the following code that should hide all controls on a form but it doesn't seem to be working can anyone please help on this.
Modules -
Function EnableDisableControls(strForm As String, intSection As Integer, fEnable As Boolean) As Boolean
' Comments : Enables or disables all controls in the specified section of the specified form
' Parameters: strForm - name of a currently open form
' intSection - number of the section to enable/disable controls in
' fEnable - True to enable controls, False to disable
' Returns : True if successful, False otherwise
'
Dim frmIn As Form
Dim ctlTmp As Control
On Error GoTo err_EnableDisableControls
Set frmIn = Forms(strForm)
For Each ctlTmp In frmIn.Controls
If ctlTmp.Section = intSection Then
On Error Resume Next
ctlTmp.Enabled = fEnable
On Error GoTo err_EnableDisableControls
End If
Next ctlTmp
EnableDisableControls = True
exit_EnableDisableControls:
Exit Function
err_EnableDisableControls:
EnableDisableControls = False
Resume exit_EnableDisableControls
End Function
On each form -
Sub DisableControls()
'Disable all controls in the detail section of the form named '????'
Dim bOK As Boolean
bOK = EnableDisableControls("CentralFunctions", 0, False)
End Sub
I will be most grateful for any help anyone can give.
Niki