incagold
Programmer
- Mar 21, 2003
- 54
Hi All,
Newbie is back with another question. We have a sub routine (code below) which we would like to assign visible and value (null) properties to the controls on a form. We need to be able to make some visible while others need to remain visible. <i> determines which ones will be visible. We also need to have all values set to null. All controls are unbound. When we run the code we get the error message:
Run-time error '2186' This property isn't available in
Design View
What are we doing wrong? Any help would be greatly appreciated and please accept our thans in advance.
Sub SetTextBoxProperties(i As Integer)
Dim frm As Form
Dim ctl As Control
Set frm = Application.Forms("frm_ADD")
'*** Enumerate Controls collection.
For Each ctl In frm.Controls
Select Case ctl.ControlType
'*** Check to see if control is text box.
Case acTextBox:
ctl.Value = null
If Val(Right(ctl.Name, 1)) > i Then
ctl.Visible = False
End If
'*** Check to see if control is combo box.
Case acComboBox:
ctl.Value = Null
'*** Check to see if control is check box.
Case acCheckBox:
ctl.Value = 0
End Select
Next ctl
End Sub
REF
Newbie is back with another question. We have a sub routine (code below) which we would like to assign visible and value (null) properties to the controls on a form. We need to be able to make some visible while others need to remain visible. <i> determines which ones will be visible. We also need to have all values set to null. All controls are unbound. When we run the code we get the error message:
Run-time error '2186' This property isn't available in
Design View
What are we doing wrong? Any help would be greatly appreciated and please accept our thans in advance.
Sub SetTextBoxProperties(i As Integer)
Dim frm As Form
Dim ctl As Control
Set frm = Application.Forms("frm_ADD")
'*** Enumerate Controls collection.
For Each ctl In frm.Controls
Select Case ctl.ControlType
'*** Check to see if control is text box.
Case acTextBox:
ctl.Value = null
If Val(Right(ctl.Name, 1)) > i Then
ctl.Visible = False
End If
'*** Check to see if control is combo box.
Case acComboBox:
ctl.Value = Null
'*** Check to see if control is check box.
Case acCheckBox:
ctl.Value = 0
End Select
Next ctl
End Sub
REF