timhans
Programmer
- Jun 24, 2009
- 75
Hello, my first attempt at coding a function, I have this
Function ClearAll()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acCheckBox
ctl.Value = Null
End If
Case Else
End Select
Next ctl
End Function
Would like to dynamicly exclude controls from being cleared
Could hard code it like
Function ClearAll()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acCheckBox
If ctl.ControlSource = "" And ctl.Name <> "CtlName" Then 'And ctl.Name <> "txtNewField1" And ctl.Name <> "txtNewField2" And ctl.Name <> "txtNewField3" Then
ctl.Value = Null
End If
Case Else
End Select
Next ctl
End Function
but again would like it to be dynamic I tried but no luck.
Thanks
Function ClearAll()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acCheckBox
ctl.Value = Null
End If
Case Else
End Select
Next ctl
End Function
Would like to dynamicly exclude controls from being cleared
Could hard code it like
Function ClearAll()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acCheckBox
If ctl.ControlSource = "" And ctl.Name <> "CtlName" Then 'And ctl.Name <> "txtNewField1" And ctl.Name <> "txtNewField2" And ctl.Name <> "txtNewField3" Then
ctl.Value = Null
End If
Case Else
End Select
Next ctl
End Function
but again would like it to be dynamic I tried but no luck.
Thanks