Chat with a LIVE Microsoft Access Expert!
 
       
 

         

   

Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
 
Chat with a LIVE Microsoft Access Expert!
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-24-2007, 08:27 AM
Wayne Cramer Wayne Cramer is offline
Registered User
 
Join Date: Aug 2007
Posts: 93
Wayne Cramer is on a distinguished road
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.
Reply With Quote
Sponsored Links
  #2  
Old 08-24-2007, 08:38 AM
CraigDolphin's Avatar
CraigDolphin CraigDolphin is offline
AWF VIP
 
Join Date: Dec 2005
Location: Bellingham, WA. USA
Posts: 1,525
CraigDolphin has a spectacular aura aboutCraigDolphin has a spectacular aura about
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).
Reply With Quote
  #3  
Old 08-24-2007, 08:50 AM
Luddite Lad's Avatar
Luddite Lad Luddite Lad is offline
Registered User
 
Join Date: Aug 2005
Posts: 177
Luddite Lad is on a distinguished road
Easy just put the following code behind your form's on close event or on a button's on click event;

Quote:
Me.Check1 = False
Me.Check2 = False
'Etc.
__________________
The Luddite Credo:
If you don’t understand how it works, hit it with a hammer, and hit it hard.
Reply With Quote
  #4  
Old 08-24-2007, 08:57 AM
boblarson's Avatar
boblarson boblarson is online now
Super Moderator
 
Join Date: Jan 2001
Posts: 22,003
boblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to all
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
__________________
Thanks,

Bob Larson

Free samples, tools and tutorials (including Auto Frontend Update Enabling Tool)

"Have you tried turning it off and on again?"
Reply With Quote
  #5  
Old 08-24-2007, 09:08 AM
CEH CEH is offline
Curtis
 
Join Date: Oct 2004
Location: Kansas
Posts: 1,163
CEH will become famous soon enough
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
Reply With Quote
  #6  
Old 08-24-2007, 09:09 AM
CraigDolphin's Avatar
CraigDolphin CraigDolphin is offline
AWF VIP
 
Join Date: Dec 2005
Location: Bellingham, WA. USA
Posts: 1,525
CraigDolphin has a spectacular aura aboutCraigDolphin has a spectacular aura about
So few cats, so many ways to skin 'em
Reply With Quote
  #7  
Old 08-24-2007, 01:42 PM
missinglinq's Avatar
missinglinq missinglinq is offline
AWF VIP
 
Join Date: Jun 2003
Location: Richmond (Virginia that is!)
Posts: 3,197
missinglinq is just really nicemissinglinq is just really nicemissinglinq is just really nicemissinglinq is just really nice
That's what I always say!
__________________
There's ALWAYS more than one way to skin a cat!
Reply With Quote
  #8  
Old 11-05-2007, 10:07 AM
BadScript BadScript is offline
Registered User
 
Join Date: Oct 2007
Posts: 73
BadScript is on a distinguished road
Thumbs up

Quote:
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
ctl.Value = False
End If
Next ctl
Many thanks, Excellent..
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 10:34 AM..
Reply With Quote
  #9  
Old 11-05-2007, 10:48 AM
KenHigg KenHigg is offline
~~~~~~~~
 
Join Date: Jun 2004
Posts: 12,298
KenHigg will become famous soon enoughKenHigg will become famous soon enough
Here's a stab:

Dim ctl As Control
For Each ctl In Me.Controls
ctl.Value = False
Next ctl

???
ken
__________________

ken
Reply With Quote
  #10  
Old 11-05-2007, 11:49 AM
boblarson's Avatar
boblarson boblarson is online now
Super Moderator
 
Join Date: Jan 2001
Posts: 22,003
boblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to all
Quote:
Originally Posted by BadScript View Post
Many thanks, Excellent..
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
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
__________________
Thanks,

Bob Larson

Free samples, tools and tutorials (including Auto Frontend Update Enabling Tool)

"Have you tried turning it off and on again?"
Reply With Quote
  #11  
Old 11-05-2007, 11:56 AM
rainman89's Avatar
rainman89 rainman89 is offline
I cant find the any key..
 
Join Date: Feb 2007
Location: New York, USA
Posts: 2,932
rainman89 has a spectacular aura aboutrainman89 has a spectacular aura about
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 2010 Win7Pro
Reply With Quote
  #12  
Old 11-05-2007, 12:02 PM
boblarson's Avatar
boblarson boblarson is online now
Super Moderator
 
Join Date: Jan 2001
Posts: 22,003
boblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to all
Quote:
Originally Posted by rainman89 View Post
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.
Voila ...
__________________
Thanks,

Bob Larson

Free samples, tools and tutorials (including Auto Frontend Update Enabling Tool)

"Have you tried turning it off and on again?"
Reply With Quote
  #13  
Old 11-05-2007, 12:02 PM
KenHigg KenHigg is offline
~~~~~~~~
 
Join Date: Jun 2004
Posts: 12,298
KenHigg will become famous soon enoughKenHigg will become famous soon enough
And Bob likes to show off...
__________________

ken
Reply With Quote
  #14  
Old 11-05-2007, 12:09 PM
BadScript BadScript is offline
Registered User
 
Join Date: Oct 2007
Posts: 73
BadScript is on a distinguished road
Quote:
Originally Posted by boblarson View Post
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
Thanks, it all works except for the clear textboxes.. I get a debug error..
Reply With Quote
  #15  
Old 11-05-2007, 12:10 PM
boblarson's Avatar
boblarson boblarson is online now
Super Moderator
 
Join Date: Jan 2001
Posts: 22,003
boblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to all
Quote:
Originally Posted by BadScript View Post
Thanks, it all works except for the clear textboxes.. I get a debug error..
What's the text of the error?
__________________
Thanks,

Bob Larson

Free samples, tools and tutorials (including Auto Frontend Update Enabling Tool)

"Have you tried turning it off and on again?"
Reply With Quote
Sponsored Links
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
check boxes jalverson Forms 1 09-27-2005 05:55 AM
And Or Criteria for check boxes help!! Karen Dawson Queries 2 04-15-2004 08:06 AM
Summing Check Boxes Pt 2 RichO Modules & VBA 3 03-01-2004 07:28 PM
Check boxes in forms Bentleybelle Forms 1 02-22-2004 12:41 PM
Check Boxes Russ Forms 1 01-26-2000 07:32 PM


All times are GMT -8. The time now is 09:58 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
(c) copyright 2009 Access World