Clearing Check Boxes

heidibbb

New Member
Joined
Dec 8, 2010
Messages
31
Hello,
I've built a form in excel using VB (very new to this). all is working fine, except when the form is filled out and submitted and resets, instead of the check boxes being cleared for the next entry, they all show as checked but greyed out.

I can still fill out the form and check the boxes I want for the next entry, but I want to be able to clear the check boxes so they are empty for the next entry. any ideas?

The code I'm using to clear the form is this... text boxes are clearing fine, it's the check boxes I'm having issues with ("cb_..."). They are technically clearing, but visually, i want them blank:

'clear the data
Me.txtFirst.Value = ""
Me.txtLast.Value = ""
Me.txtTitle.Value = ""
Me.txtSchool.Value = ""
Me.txtAddress.Value = ""
Me.txtCity.Value = ""
Me.txtState.Value = ""
Me.txtZip.Value = ""
Me.txtEmail.Value = ""
Me.txtPhone.Value = ""

Me.cb_SOS.Value = ""
Me.cb_DSCR.Value = ""
Me.cb_DSR.Value = ""
Me.cb_DSFR.Value = ""
Me.cb_SPIRE.Value = ""
Me.cb_ETC.Value = ""
Me.cb_WW3000.Value = ""
Me.cb_MC.Value = ""
Me.cb_MCI.Value = ""
Me.cb_AOR.Value = ""

Me.cb_AdoptScience.Value = ""
Me.cb_AdoptMath.Value = ""
Me.cb_AdoptLiteracy.Value = ""
Me.cb_AdoptNone.Value = ""

Me.cb_SalesYes.Value = ""
Me.cb_RaffleYes.Value = ""

Me.txt_Comments.Value = ""

I'm sure this is probably an easy answer... but like I said... I'm new at this!

thanks!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Are the checkboxes linked to cells?
 
Upvote 0
Instead of setting them to a value of "" set them to False. Then they will be unchecked and not grayed out.
 
Upvote 0
Instead of resetting each individual checkbox to false you could try:

PHP:
    For Each Control In UserForm1.controls
      If TypeName(Control) = "CheckBox" Then
          Control.Value = False
      End If
    Next control

I have this placed into the code after the data is placed on the spreadsheet from the userform. Obviously you'll have to change "UserForm1" above to whatever yours is called.

Hope that helps
 
Upvote 0

Forum statistics

Threads
1,224,612
Messages
6,179,890
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top