A
Andrew R
Hi
I have the following sub in an Access database, the idea of which is to
clear all controls on a passed form. But when I run it, I get the error
message "You can't assign a value to this object" at the very first
text box it hits! I assign a value to the text box (from a recordset)
at the load event without problem, so I'm a bit stumped...
Any thoughts?
Andrew
Public Sub ClearForm(frmClearedForm As Form)
Dim ctl As Control
'Cycle through the controls
For Each ctl In frmClearedForm
'Test if they are textboxes, listboxes etc
If TypeOf ctl Is TextBox Then ctl = "a"
If TypeOf ctl Is ComboBox Or TypeOf ctl Is ListBox Then
ctl.ListIndex = 0
If TypeOf ctl Is CheckBox Then ctl.Value = False
If TypeOf ctl Is OptionButton Then ctl.Value = False
Next ctl
End Sub
I have the following sub in an Access database, the idea of which is to
clear all controls on a passed form. But when I run it, I get the error
message "You can't assign a value to this object" at the very first
text box it hits! I assign a value to the text box (from a recordset)
at the load event without problem, so I'm a bit stumped...
Any thoughts?
Andrew
Public Sub ClearForm(frmClearedForm As Form)
Dim ctl As Control
'Cycle through the controls
For Each ctl In frmClearedForm
'Test if they are textboxes, listboxes etc
If TypeOf ctl Is TextBox Then ctl = "a"
If TypeOf ctl Is ComboBox Or TypeOf ctl Is ListBox Then
ctl.ListIndex = 0
If TypeOf ctl Is CheckBox Then ctl.Value = False
If TypeOf ctl Is OptionButton Then ctl.Value = False
Next ctl
End Sub