Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
=EMBED("Forms.TextBox.1","") | Excel Discussion (Misc queries) | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
"Invalid property" after "Clear Form" | Excel Programming | |||
Disable Close "X" button on User Forms | Excel Programming | |||
Disable Close "X" button on User Forms | Excel Programming |