PC Review


Reply
Thread Tools Rate Thread

Code to clear all CheckNBoxes when a Form loads

 
 
ryguy7272
Guest
Posts: n/a
 
      9th Feb 2010
I have 20 CheckBoxes on a Form. All are set to Triple State = No. When the
Form opens, all CheckBoxes, except one, always has a solid green square in
the middle. I check off all CheckBoxes, close the Form, and all will have
the tiny green square in there again. Is there some setting that manages
this? If not, can I add a snippet of code to clear all CheckNBoxes when the
Form loads?

Thanks!
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.
 
Reply With Quote
 
 
 
 
Jack Leach
Guest
Posts: n/a
 
      9th Feb 2010
I'm not sure why they're acting like that, but you can probably run through
them in an open event and set them to false...

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
ctl = False
End If
Next


I think that would effectively all the check boxes to false, though I have
no idea why they would do that to begin with.
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



"ryguy7272" wrote:

> I have 20 CheckBoxes on a Form. All are set to Triple State = No. When the
> Form opens, all CheckBoxes, except one, always has a solid green square in
> the middle. I check off all CheckBoxes, close the Form, and all will have
> the tiny green square in there again. Is there some setting that manages
> this? If not, can I add a snippet of code to clear all CheckNBoxes when the
> Form loads?
>
> Thanks!
> Ryan---
>
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      9th Feb 2010
Thanks for the code, Jack! It worked perfect!! I have no idea why it is
doing this, but when I opened the form this morning, same thing. I popped
your code in there, closed it and opened it, and now it works like a normal
form.


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Jack Leach" wrote:

> I'm not sure why they're acting like that, but you can probably run through
> them in an open event and set them to false...
>
> Dim ctl As Control
> For Each ctl In Me.Controls
> If ctl.ControlType = acCheckBox Then
> ctl = False
> End If
> Next
>
>
> I think that would effectively all the check boxes to false, though I have
> no idea why they would do that to begin with.
> --
> Jack Leach
> www.tristatemachine.com
>
> "I haven''t failed, I''ve found ten thousand ways that don''t work."
> -Thomas Edison (1847-1931)
>
>
>
> "ryguy7272" wrote:
>
> > I have 20 CheckBoxes on a Form. All are set to Triple State = No. When the
> > Form opens, all CheckBoxes, except one, always has a solid green square in
> > the middle. I check off all CheckBoxes, close the Form, and all will have
> > the tiny green square in there again. Is there some setting that manages
> > this? If not, can I add a snippet of code to clear all CheckNBoxes when the
> > Form loads?
> >
> > Thanks!
> > Ryan---
> >
> >
> > --
> > Ryan---
> > If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
Jack Leach
Guest
Posts: n/a
 
      9th Feb 2010
Strange though.... I don't like it. Like fixing an oil leak by dumping more
oil in instead of plugging the leak. I can't image what might be causing it
to begin with...

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



"ryguy7272" wrote:

> Thanks for the code, Jack! It worked perfect!! I have no idea why it is
> doing this, but when I opened the form this morning, same thing. I popped
> your code in there, closed it and opened it, and now it works like a normal
> form.
>
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.
>
>
> "Jack Leach" wrote:
>
> > I'm not sure why they're acting like that, but you can probably run through
> > them in an open event and set them to false...
> >
> > Dim ctl As Control
> > For Each ctl In Me.Controls
> > If ctl.ControlType = acCheckBox Then
> > ctl = False
> > End If
> > Next
> >
> >
> > I think that would effectively all the check boxes to false, though I have
> > no idea why they would do that to begin with.
> > --
> > Jack Leach
> > www.tristatemachine.com
> >
> > "I haven''t failed, I''ve found ten thousand ways that don''t work."
> > -Thomas Edison (1847-1931)
> >
> >
> >
> > "ryguy7272" wrote:
> >
> > > I have 20 CheckBoxes on a Form. All are set to Triple State = No. When the
> > > Form opens, all CheckBoxes, except one, always has a solid green square in
> > > the middle. I check off all CheckBoxes, close the Form, and all will have
> > > the tiny green square in there again. Is there some setting that manages
> > > this? If not, can I add a snippet of code to clear all CheckNBoxes when the
> > > Form loads?
> > >
> > > Thanks!
> > > Ryan---
> > >
> > >
> > > --
> > > Ryan---
> > > If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
Paolo
Guest
Posts: n/a
 
      9th Feb 2010
Hi again Ryan,
I can explain you the behaviour of your check boxes.
I think that all except 1 are unbound so when you open the form access don't
know the value to give to the various check boxes. If you set a default value
in the properties of the check boxes (0=unchecked, -1=checked) you'll fix it.
Perhaps also the check box that's not dimmed when you open the form is
unbound but you setted for it a default value.

HTH Paolo

"ryguy7272" wrote:

> I have 20 CheckBoxes on a Form. All are set to Triple State = No. When the
> Form opens, all CheckBoxes, except one, always has a solid green square in
> the middle. I check off all CheckBoxes, close the Form, and all will have
> the tiny green square in there again. Is there some setting that manages
> this? If not, can I add a snippet of code to clear all CheckNBoxes when the
> Form loads?
>
> Thanks!
> Ryan---
>
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      9th Feb 2010
You were exactly right Paolo! I corrected the discrepancy and commented out
the code because I don't want code running but I do want to keep it for
future use as I can foresee that coming in handy in some other project some
day.

Thanks guys!!

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Paolo" wrote:

> Hi again Ryan,
> I can explain you the behaviour of your check boxes.
> I think that all except 1 are unbound so when you open the form access don't
> know the value to give to the various check boxes. If you set a default value
> in the properties of the check boxes (0=unchecked, -1=checked) you'll fix it.
> Perhaps also the check box that's not dimmed when you open the form is
> unbound but you setted for it a default value.
>
> HTH Paolo
>
> "ryguy7272" wrote:
>
> > I have 20 CheckBoxes on a Form. All are set to Triple State = No. When the
> > Form opens, all CheckBoxes, except one, always has a solid green square in
> > the middle. I check off all CheckBoxes, close the Form, and all will have
> > the tiny green square in there again. Is there some setting that manages
> > this? If not, can I add a snippet of code to clear all CheckNBoxes when the
> > Form loads?
> >
> > Thanks!
> > Ryan---
> >
> >
> > --
> > Ryan---
> > If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
 
 
Reply

Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I have some code which loads a form in Excel on startup vbnewbie Microsoft Excel Programming 2 5th May 2009 04:38 PM
Clear form value after report loads Jake F Microsoft Access Forms 1 9th Sep 2008 02:59 AM
Clear all fields when form loads. =?Utf-8?B?WWVhaHllYWh5ZWFo?= Microsoft Access 9 15th Mar 2006 08:31 PM
Cannot Clear the text when a Form Loads =?Utf-8?B?QW5keQ==?= Microsoft Access 1 16th Jun 2004 08:24 AM
Beginner question: where to put code when form loads TBA Microsoft Excel Programming 4 31st Aug 2003 09:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:16 PM.