Check boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a check box on a form that says "All States". When this is checked i
want all the states to autimatically be checked. Any suggestions?
 
I have a check box on a form that says "All States".
When this is checked i want all the states to autimatically
be checked. Any suggestions?

If we knew what else besides this check box was on the Form and how the data
is stored in the underlying Table(s), perhaps someone could offer
suggestions. Without that knowledge, we could only guess, and that is not a
productive mode of operation.

Larry Linson
Microsoft Access MVP
 
While I agree with Larry, let me take a stab at what I think JJ might be
getting at:

I envision your form as having all the States listed with a checkbox beside
each. In addition, you want to have another checkbox that means, if checked,
automatically chceck all the States.

If so, then I think it's pretty easy. (Famous last words.)

Set the Click event of the "All" checkbox to a [procedure event] and place
code within it that, if the check-box is true, will set the checkboxes of all
the others to true. Now, you'll have to decide what to do if it's false. You
could, of course, leave things alone, which would probably be a good idea
because then, if your user wanted to check all but a couple or so of States,
he could do this by clicking All and then unclicking the States not wanted.
Or, perhaps if unchecked, you'll want to set the State checkboxes to false.
Whatever.

If this is on the right track, and you need a little help with the code, let
us know. Otherwise, good luck.

Kerry
 
Thanks Kerry. That is exactly what I want to do. Should I use the update
method?

Kerry said:
While I agree with Larry, let me take a stab at what I think JJ might be
getting at:

I envision your form as having all the States listed with a checkbox beside
each. In addition, you want to have another checkbox that means, if checked,
automatically chceck all the States.

If so, then I think it's pretty easy. (Famous last words.)

Set the Click event of the "All" checkbox to a [procedure event] and place
code within it that, if the check-box is true, will set the checkboxes of all
the others to true. Now, you'll have to decide what to do if it's false. You
could, of course, leave things alone, which would probably be a good idea
because then, if your user wanted to check all but a couple or so of States,
he could do this by clicking All and then unclicking the States not wanted.
Or, perhaps if unchecked, you'll want to set the State checkboxes to false.
Whatever.

If this is on the right track, and you need a little help with the code, let
us know. Otherwise, good luck.

Kerry

Larry Linson said:
If we knew what else besides this check box was on the Form and how the data
is stored in the underlying Table(s), perhaps someone could offer
suggestions. Without that knowledge, we could only guess, and that is not a
productive mode of operation.

Larry Linson
Microsoft Access MVP
 
JJ,

You could, but that would, in this case, be a complicated way of doing it.
(It is good to know that method because it often is very useful, especially
for making "behind the scenes" updates to non-displayed data. But that's
another topic.)

All you need to do is something like as follows (where I'm not try to be
exactly correct in my syntax...I'll leave that as an "exercise"):

sub chkAll_Click()

on error goto ...

if (me.ckhAll) then
me.chkAlabama = True
me.chkAlaska = True
...
else
...whatever it is you want to do if the user unchecks chkAll...
endif
....

Get the idea?

Obviously, your check box names and so forth might be different, but I'm
sure you get the idea.

Hope this helps.

Kerry

JJ said:
Thanks Kerry. That is exactly what I want to do. Should I use the update
method?

Kerry said:
While I agree with Larry, let me take a stab at what I think JJ might be
getting at:

I envision your form as having all the States listed with a checkbox beside
each. In addition, you want to have another checkbox that means, if checked,
automatically chceck all the States.

If so, then I think it's pretty easy. (Famous last words.)

Set the Click event of the "All" checkbox to a [procedure event] and place
code within it that, if the check-box is true, will set the checkboxes of all
the others to true. Now, you'll have to decide what to do if it's false. You
could, of course, leave things alone, which would probably be a good idea
because then, if your user wanted to check all but a couple or so of States,
he could do this by clicking All and then unclicking the States not wanted.
Or, perhaps if unchecked, you'll want to set the State checkboxes to false.
Whatever.

If this is on the right track, and you need a little help with the code, let
us know. Otherwise, good luck.

Kerry

Larry Linson said:
I have a check box on a form that says "All States".
When this is checked i want all the states to autimatically
be checked. Any suggestions?

If we knew what else besides this check box was on the Form and how the data
is stored in the underlying Table(s), perhaps someone could offer
suggestions. Without that knowledge, we could only guess, and that is not a
productive mode of operation.

Larry Linson
Microsoft Access MVP
 
Back
Top