RosemaryJB
Registered User.
- Local time
- Today, 17:29
- Joined
- Nov 6, 2006
- Messages
- 24
My apologies if you have already seen this - I added it to another, related thread but as no-one answered thought it might be overlooked.
I reset all the fields on a search form - Do I = 0 to Count etc.
This works for fine all (textbox, combobox, listbox, toggle buttton) except optionbutton which VB won't let me, saying I can't set a value to this field.
I've tried setting the optionbuttons to 0, defaultvalue & false.
I have to list each optionbutton individually & set them to 0.
As this is a form which changes frequently I'd prefer to Do I = 0 to Count rather than hard-code the field:
Any suggestions please - see code below
Private Sub ClrFilter_Click()
'Clear filter entries from screen
Dim I As Integer
Dim Index As Integer
For I = 0 To Forms![Frm Contacts Search].Count - 1
If TypeOf Forms Is TextBox Then
Forms = ""
ElseIf TypeOf Forms Is ComboBox Then
Forms = ""
ElseIf TypeOf Forms Is ListBox Then
For Index = 0 To Forms.ListCount - 1
Forms.Selected(Index) = False
Next Index
'next bit doesn't work
ElseIf TypeOf Forms Is OptionButton Then
Forms = 0
ElseIf TypeOf Forms Is ToggleButton Then
Forms.Value = Forms.DefaultValue
End If
Next I
'Option buttons - this works
Me!Broxbourne = 0
Me!Dacorum = 0
'etc - unfortunately there are lots of these!
End Sub
Reply With Quote
I reset all the fields on a search form - Do I = 0 to Count etc.
This works for fine all (textbox, combobox, listbox, toggle buttton) except optionbutton which VB won't let me, saying I can't set a value to this field.
I've tried setting the optionbuttons to 0, defaultvalue & false.
I have to list each optionbutton individually & set them to 0.
As this is a form which changes frequently I'd prefer to Do I = 0 to Count rather than hard-code the field:
Any suggestions please - see code below
Private Sub ClrFilter_Click()
'Clear filter entries from screen
Dim I As Integer
Dim Index As Integer
For I = 0 To Forms![Frm Contacts Search].Count - 1
If TypeOf Forms Is TextBox Then
Forms = ""
ElseIf TypeOf Forms Is ComboBox Then
Forms = ""
ElseIf TypeOf Forms Is ListBox Then
For Index = 0 To Forms.ListCount - 1
Forms.Selected(Index) = False
Next Index
'next bit doesn't work
ElseIf TypeOf Forms Is OptionButton Then
Forms = 0
ElseIf TypeOf Forms Is ToggleButton Then
Forms.Value = Forms.DefaultValue
End If
Next I
'Option buttons - this works
Me!Broxbourne = 0
Me!Dacorum = 0
'etc - unfortunately there are lots of these!
End Sub
Reply With Quote