ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   User forms "Clear" (https://www.excelbanter.com/excel-programming/388536-user-forms-clear.html)

Lime

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



Luis Fernando Ortiz M.[_2_]

User forms "Clear"
 
Hi,

Try this: Unload and Show the UserForm at the same Sub, this procedure clean
all controls in the UserForm

Regards,

Fernando Ortiz


"Lime" escribió en el mensaje
...
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





Lime

User forms "Clear"
 
Hi,
I'm sorry but I do not understand? Can you give a little exsample to get
started?

Lime

"Luis Fernando Ortiz M." wrote:

Hi,

Try this: Unload and Show the UserForm at the same Sub, this procedure clean
all controls in the UserForm

Regards,

Fernando Ortiz


"Lime" escribió en el mensaje
...
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






Susan

User forms "Clear"
 
what he means is:

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


unload me
load userform1
userform1.show
end if

end sub

unloading & reloading the sub will clear the form. OR, this is what i
do. in my userform_initialization sub i have everything set to open
with nothing in the boxes & ranges, etc. so when i want to clear the
form, i have it call the initialization sub & basically "reset" the
form.

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
call userform_initialization
end if
end sub

hope it helps!
susan


On May 1, 8:18 pm, Lime wrote:
Hi,
I'm sorry but I do not understand? Can you give a little exsample to get
started?

Lime

"Luis Fernando Ortiz M." wrote:



Hi,


Try this: Unload and Show the UserForm at the same Sub, this procedure clean
all controls in the UserForm


Regards,


Fernando Ortiz


"Lime" escribió en el mensaje
...
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- Hide quoted text -


- Show quoted text -




Lime

User forms "Clear"
 
Thanks but I have multipal forms in one workbook that all need to be cleared
as one time.

"Susan" wrote:

what he means is:

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


unload me
load userform1
userform1.show
end if

end sub

unloading & reloading the sub will clear the form. OR, this is what i
do. in my userform_initialization sub i have everything set to open
with nothing in the boxes & ranges, etc. so when i want to clear the
form, i have it call the initialization sub & basically "reset" the
form.

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
call userform_initialization
end if
end sub

hope it helps!
susan


On May 1, 8:18 pm, Lime wrote:
Hi,
I'm sorry but I do not understand? Can you give a little exsample to get
started?

Lime

"Luis Fernando Ortiz M." wrote:



Hi,


Try this: Unload and Show the UserForm at the same Sub, this procedure clean
all controls in the UserForm


Regards,


Fernando Ortiz


"Lime" escribió en el mensaje
...
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- Hide quoted text -


- Show quoted text -





Susan

User forms "Clear"
 
On May 2, 10:05 am, Lime wrote:
Thanks but I have multipal forms in one workbook that all need to be cleared
as one time.


sub clear_multiple()
call userform1_initialize
call userform2_initialize
call userform3_initialize
end sub

should work
susan



All times are GMT +1. The time now is 10:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com