![]() |
Visual Basic Form
Can anyone tell me how to clear a form? When I first pull my form up, which
has radio buttons with code, the buttons are clear but after I make a choice and pull it up again button is still indicated. I have to close the form and re-open it once again to clear. What am I not doing correctly? Thx -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200801/1 |
Visual Basic Form
Do you hide the userform and then show it?
If yes, try unloading and then loading it. "Carrie_Loos via OfficeKB.com" wrote: Can anyone tell me how to clear a form? When I first pull my form up, which has radio buttons with code, the buttons are clear but after I make a choice and pull it up again button is still indicated. I have to close the form and re-open it once again to clear. What am I not doing correctly? Thx -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200801/1 -- Dave Peterson |
Visual Basic Form
Try this: should work for both textbox & optionbutton
Private Sub CommandButton1_Click() ' Clear the form Dim ctrl As Control For Each ctrl In Me.Controls If TypeOf ctrl Is MSForms.TextBox Then ctrl.Value = "" ElseIf TypeOf ctrl Is MSForms.OptionButton Then ctrl.Value = False End If Next ctrl End Sub "Carrie_Loos via OfficeKB.com" wrote: Can anyone tell me how to clear a form? When I first pull my form up, which has radio buttons with code, the buttons are clear but after I make a choice and pull it up again button is still indicated. I have to close the form and re-open it once again to clear. What am I not doing correctly? Thx -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200801/1 |
Visual Basic Form
This works well - Thanks
Alpineman2 wrote: Try this: should work for both textbox & optionbutton Private Sub CommandButton1_Click() ' Clear the form Dim ctrl As Control For Each ctrl In Me.Controls If TypeOf ctrl Is MSForms.TextBox Then ctrl.Value = "" ElseIf TypeOf ctrl Is MSForms.OptionButton Then ctrl.Value = False End If Next ctrl End Sub Can anyone tell me how to clear a form? When I first pull my form up, which has radio buttons with code, the buttons are clear but after I make a choice and pull it up again button is still indicated. I have to close the form and re-open it once again to clear. What am I not doing correctly? Thx -- Message posted via http://www.officekb.com |
All times are GMT +1. The time now is 06:45 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com