Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default 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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default 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 -



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default 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 -






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default 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

Reply
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 11:50 AM.

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"