| Chat with a LIVE Microsoft
Access Expert! |
||||
|
||||
|
#1
|
|||
|
|||
|
Clear all check boxes
I have a form with a check box that controls a report which sends faxes to appropriate recipients. When the form closes I would like all check boxes to clear so the next time it is opened I can select recipients. Currently I have to deselect each check box one by one. A control button which would clear all check boxes would be a good solution also.
|
| Sponsored Links |
|
#2
|
||||
|
||||
|
Are the checkboxes bound to any fields or are they unbound?
If they are unbound, then change the default value to 0 (i.e., false). If they are bound to a field, then you could create an update query that runs from vba code in the on_close event of the form and changes all the -1 (true) values in the form's record source to 0. You could use a similar approach in a command button also but, if you always want to do this when the form opens, you'd be better to use the on_close event of the form (or the on_current event instead if you want it to reset when you navigate off the record). |
|
#3
|
||||
|
||||
|
Easy just put the following code behind your form's on close event or on a button's on click event;
Quote:
__________________
The Luddite Credo: If you don’t understand how it works, hit it with a hammer, and hit it hard. |
|
#4
|
||||
|
||||
|
This will clear all checkboxes on a form.
Code:
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
ctl.Value = False
End If
Next ctl
__________________
Bob Larson Free Access Tutorials and Samples: http://www.btabdevelopment.com (and FREE frontend auto update enabling tool) |
|
#5
|
|||
|
|||
|
To add to Bobs post... in case you might have other check boxes on the form you do not want to change by the event, you could "Tag" the ones you DO want to clear.....
Dim ctl As Control For Each ctl In Me.Controls If ctl.ControlType = acCheckBox Then If ctl.tag = "*" then ctl.Value = False End If End if Next ctl
__________________
Curtis |
|
#6
|
||||
|
||||
|
So few cats, so many ways to skin 'em
![]() |
|
#7
|
||||
|
||||
|
That's what I always say!
__________________
There's ALWAYS more than one way to skin a cat! |
|
#8
|
|||
|
|||
|
Quote:
Is this possible for other controls as well? like clear all combo's and clear all textboxes or clear a whole form? I have many controls in my unbound form and all I want is to clear my form with a button Last edited by BadScript; 11-05-2007 at 11:34 AM.. |
|
#9
|
|||
|
|||
|
Here's a stab:
Dim ctl As Control For Each ctl In Me.Controls ctl.Value = False Next ctl ??? ken
__________________
![]() ken |
|
#10
|
||||
|
||||
|
Quote:
Code:
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acCheckBox
ctl.Value = False
Case acComboBox
ctl.Value = Null
Case acTextBox
ctl.Value = ""
End Select
Next ctl
__________________
Bob Larson Free Access Tutorials and Samples: http://www.btabdevelopment.com (and FREE frontend auto update enabling tool) |
|
#11
|
||||
|
||||
|
this thread is perfect. i said to myself this morning.. self.. wouldnt it be great if you had a select all option adn clear all option for the checkboxes?
and vualah?(sp i think its french or something) i found this thread.
__________________
Ray____________________________________ (If someone has helped you, please add to their reputation by clicking on the icon above that looks like the scales) Access 2007 Win 7 Pro |
|
#12
|
||||
|
||||
|
Quote:
...
__________________
Bob Larson Free Access Tutorials and Samples: http://www.btabdevelopment.com (and FREE frontend auto update enabling tool) |
|
#13
|
|||
|
|||
|
And Bob likes to show off...
![]()
__________________
![]() ken |
|
#14
|
|||
|
|||
|
Thanks, it all works except for the clear textboxes.. I get a debug error..
|
|
#15
|
||||
|
||||
|
What's the text of the error?
__________________
Bob Larson Free Access Tutorials and Samples: http://www.btabdevelopment.com (and FREE frontend auto update enabling tool) |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| check boxes | jalverson | Forms | 1 | 09-27-2005 06:55 AM |
| And Or Criteria for check boxes help!! | Karen Dawson | Queries | 2 | 04-15-2004 09:06 AM |
| Summing Check Boxes Pt 2 | RichO | Modules & VBA | 3 | 03-01-2004 08:28 PM |
| Check boxes in forms | Bentleybelle | Forms | 1 | 02-22-2004 01:41 PM |
| Check Boxes | Russ | Forms | 1 | 01-26-2000 08:32 PM |