LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default User forms "Clear"

Hello,
I have a bunch of user forms with in a workbook. I have a button on sheet1
that is to clear the check boxes, list boxes..etc...of all the user forms,
but the code I have below only works some of the time clearing all the forms.
other times I have to click the clear button on sheet one several times to
get all the user forms to clear. Can anyone please take a look at the below
code and let me know what I'm doing worng/missing.

greatful for any help.... Lime
Private Sub cmdbtnnextcase_Click()

Dim smessage As String
smessage = "Are you sure you want to Start a New Case?" + " All
information will be cleared."
If MsgBox(smessage, vbQuestion + vbYesNo, _
"Start a New Case") = vbYes Then

For Each ctrl In frmBackPain.Controls
If TypeName(ctrl) = "CheckBox" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "OptionButton" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "TextBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ComboBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ListBox" Then
ctrl.Value = ""
End If
Next ctrl

For Each ctrl In frmCADMI.Controls
If TypeName(ctrl) = "CheckBox" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "OptionButton" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "TextBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ComboBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ListBox" Then
ctrl.Value = ""
End If
Next ctrl

For Each ctrl In frmCOPD.Controls
If TypeName(ctrl) = "CheckBox" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "OptionButton" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "TextBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ComboBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ListBox" Then
ctrl.Value = ""
End If
Next ctrl

For Each ctrl In frmcva.Controls
If TypeName(ctrl) = "CheckBox" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "OptionButton" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "TextBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ComboBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ListBox" Then
ctrl.Value = ""
End If

Next ctrl

For Each ctrl In frmesrdckd.Controls
If TypeName(ctrl) = "CheckBox" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "OptionButton" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "TextBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ComboBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ListBox" Then
ctrl.Value = ""
End If
Next ctrl

For Each ctrl In frmGenMed.Controls
If TypeName(ctrl) = "CheckBox" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "OptionButton" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "TextBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ComboBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ListBox" Then
ctrl.Value = ""
End If
Next ctrl

For Each ctrl In frmHeartFailure.Controls
If TypeName(ctrl) = "CheckBox" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "OptionButton" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "TextBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ComboBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ListBox" Then
ctrl.Value = ""
End If
Next ctrl

For Each ctrl In usrfrmhighriskcriteria.Controls
If TypeName(ctrl) = "OptionButton" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "CheckBox" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "TextBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ComboBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ListBox" Then
ctrl.Value = ""
End If

Next ctrl


For Each ctrl In frmpancreatitis.Controls
If TypeName(ctrl) = "CheckBox" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "OptionButton" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "TextBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ComboBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ListBox" Then
ctrl.Value = ""
End If
Next ctrl


For Each ctrl In usrfrmsavingscalc.Controls
If TypeName(ctrl) = "CheckBox" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "OptionButton" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "TextBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ComboBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ListBox" Then
ctrl.Value = ""
End If

Next ctrl

For Each ctrl In usrfrmprofile.Controls
If TypeName(ctrl) = "CheckBox" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "OptionButton" Then
ctrl.Value = False
ElseIf TypeName(ctrl) = "TextBox" Then
ctrl.Value = ""
ElseIf TypeName(ctrl) = "ComboBox" Then
ctrl.Value = ""
End If
Next ctrl


Sheet3.Range("N2:N3") = ""
Sheet3.Range("H19:H21") = ""
usrfrmprofile.cmbobxprofilelinquistic = "English"

Sheet1.Range("C5") = "Select Condition"
ckbxinfoby = "Member"
Sheet1.Range("A12") = ""
Sheet1.Range("A7:G8") = ""
Sheet1.Range("A9:G10") = ""
Sheet3.Range("A93") = ""
Sheet3.Range("N2:N3") = ""
Sheet3.Range("X2:X10") = ""
Sheet3.Range("K1:K14") = ""
Sheet3.Range("AD12:AF12") = ""
Sheet3.Range("AD2:AE7") = ""
usrfrmprofile.Show
End If

End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
=EMBED("Forms.TextBox.1","") Lynda Excel Discussion (Misc queries) 1 September 28th 09 03:23 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
"Invalid property" after "Clear Form" B[_4_] Excel Programming 1 April 19th 06 04:57 AM
Disable Close "X" button on User Forms Celtic_Avenger[_50_] Excel Programming 0 October 11th 04 06:25 PM
Disable Close "X" button on User Forms Celtic_Avenger[_49_] Excel Programming 2 October 11th 04 06:20 PM


All times are GMT +1. The time now is 04:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"