Checkbox Click (and Afterupdate?)

I have a form with multiple checkboxes in the following format:
_X_ Northeast
  _X_ New England   _X_ State1  _X_ State2 ...
  _X_ Mid Atlantic   _X_ State5  _X_ State6 ...

Using the following code in the On Click Event I was able to select all the 
states in each row (i.e. all the states in New England):
If (Me."New England") Then
  Me.State1 = True
  Me.State2 = True
  ...
Else
  Me.State1 = False
  Me.State2 = False
  ...
End If 

I thought that if I were to apply the same principle to the "Northeast" 
checkbox...:
If (Me."Northeast") Then
  Me."New England" = True
  Me."Mid Atlantic" = True
Else
  Me."New England" = False
  Me."Mid Atlantic" = False
End If

....clicking the "Northeast" would select the "New England" and "Mid 
Atlantic" boxes, (which would in turn select all the states).  However, 
clicking the "Northeast" checkbox only selects the "New England" and "Mid 
Atlantic" boxes, NOT any of the states.  

What code am I missing?  An Afterupdate event? And would it be placed: in 
the "Northeast" checkbox, "New England" checkbox, or in each state's checkbox?
0
Utf
5/15/2007 5:56:02 PM
access.forms 6864 articles. 2 followers. Follow

7 Replies
740 Views

Similar Articles

[PageSpeed] 59

First, you should not be putting quotes around control names

> If (Me."Northeast") Then
Should be
> If (Me.Northeast) Then

Then, you are specifying regions, not states.
You can't cascade the controls like that, you have to do them all by hand.
-- 
Dave Hargis, Microsoft Access MVP


"Kevin M." wrote:

> I have a form with multiple checkboxes in the following format:
> _X_ Northeast
>   _X_ New England   _X_ State1  _X_ State2 ...
>   _X_ Mid Atlantic   _X_ State5  _X_ State6 ...
> 
> Using the following code in the On Click Event I was able to select all the 
> states in each row (i.e. all the states in New England):
> If (Me."New England") Then
>   Me.State1 = True
>   Me.State2 = True
>   ...
> Else
>   Me.State1 = False
>   Me.State2 = False
>   ...
> End If 
> 
> I thought that if I were to apply the same principle to the "Northeast" 
> checkbox...:
> If (Me."Northeast") Then
>   Me."New England" = True
>   Me."Mid Atlantic" = True
> Else
>   Me."New England" = False
>   Me."Mid Atlantic" = False
> End If
> 
> ...clicking the "Northeast" would select the "New England" and "Mid 
> Atlantic" boxes, (which would in turn select all the states).  However, 
> clicking the "Northeast" checkbox only selects the "New England" and "Mid 
> Atlantic" boxes, NOT any of the states.  
> 
> What code am I missing?  An Afterupdate event? And would it be placed: in 
> the "Northeast" checkbox, "New England" checkbox, or in each state's checkbox?
0
Utf
5/15/2007 6:30:00 PM
Thanks for getting back to me.  I only had the quotation marks around the 
control names because I was calling them something else and was trying to 
make my question easier to follow...

I thought it was possible to call Subs in an AfterUpdate?  If, in my example 
below, the event New_England_Click() selects all the states' checkboxes, and 
the event Northeast_Click() checks the New_England checkbox, putting an 
afterupdate on the Northeast checkbox something very roughly along the lines 
of...:

Private Sub Northeast_AfterUpate()
  Sub New_England_Click()
End Sub

....so the code in effect is 'saying':
 "OK, Northeast checkbox = True = New_England checkbox, now go back and run 
the Sub for New_England_Click(). If New_England checkbox = True, then State1 
= True, State2 = True, etc...."

Thanks again for your help.

"Klatuu" wrote:

> First, you should not be putting quotes around control names
> 
> > If (Me."Northeast") Then
> Should be
> > If (Me.Northeast) Then
> 
> Then, you are specifying regions, not states.
> You can't cascade the controls like that, you have to do them all by hand.
> -- 
> Dave Hargis, Microsoft Access MVP
> 
> 
> "Kevin M." wrote:
> 
> > I have a form with multiple checkboxes in the following format:
> > _X_ Northeast
> >   _X_ New England   _X_ State1  _X_ State2 ...
> >   _X_ Mid Atlantic   _X_ State5  _X_ State6 ...
> > 
> > Using the following code in the On Click Event I was able to select all the 
> > states in each row (i.e. all the states in New England):
> > If (Me."New England") Then
> >   Me.State1 = True
> >   Me.State2 = True
> >   ...
> > Else
> >   Me.State1 = False
> >   Me.State2 = False
> >   ...
> > End If 
> > 
> > I thought that if I were to apply the same principle to the "Northeast" 
> > checkbox...:
> > If (Me."Northeast") Then
> >   Me."New England" = True
> >   Me."Mid Atlantic" = True
> > Else
> >   Me."New England" = False
> >   Me."Mid Atlantic" = False
> > End If
> > 
> > ...clicking the "Northeast" would select the "New England" and "Mid 
> > Atlantic" boxes, (which would in turn select all the states).  However, 
> > clicking the "Northeast" checkbox only selects the "New England" and "Mid 
> > Atlantic" boxes, NOT any of the states.  
> > 
> > What code am I missing?  An Afterupdate event? And would it be placed: in 
> > the "Northeast" checkbox, "New England" checkbox, or in each state's checkbox?
0
Utf
5/15/2007 8:52:00 PM
You can call subs and function from anywhere as long as they are within 
scope.  If they are not,  you will get an error.
Sorry, but the quotes do not clarify, they confuse.  If you can post the 
exact code, perhaps we can help.
-- 
Dave Hargis, Microsoft Access MVP


"Kevin M." wrote:

> Thanks for getting back to me.  I only had the quotation marks around the 
> control names because I was calling them something else and was trying to 
> make my question easier to follow...
> 
> I thought it was possible to call Subs in an AfterUpdate?  If, in my example 
> below, the event New_England_Click() selects all the states' checkboxes, and 
> the event Northeast_Click() checks the New_England checkbox, putting an 
> afterupdate on the Northeast checkbox something very roughly along the lines 
> of...:
> 
> Private Sub Northeast_AfterUpate()
>   Sub New_England_Click()
> End Sub
> 
> ...so the code in effect is 'saying':
>  "OK, Northeast checkbox = True = New_England checkbox, now go back and run 
> the Sub for New_England_Click(). If New_England checkbox = True, then State1 
> = True, State2 = True, etc...."
> 
> Thanks again for your help.
> 
> "Klatuu" wrote:
> 
> > First, you should not be putting quotes around control names
> > 
> > > If (Me."Northeast") Then
> > Should be
> > > If (Me.Northeast) Then
> > 
> > Then, you are specifying regions, not states.
> > You can't cascade the controls like that, you have to do them all by hand.
> > -- 
> > Dave Hargis, Microsoft Access MVP
> > 
> > 
> > "Kevin M." wrote:
> > 
> > > I have a form with multiple checkboxes in the following format:
> > > _X_ Northeast
> > >   _X_ New England   _X_ State1  _X_ State2 ...
> > >   _X_ Mid Atlantic   _X_ State5  _X_ State6 ...
> > > 
> > > Using the following code in the On Click Event I was able to select all the 
> > > states in each row (i.e. all the states in New England):
> > > If (Me."New England") Then
> > >   Me.State1 = True
> > >   Me.State2 = True
> > >   ...
> > > Else
> > >   Me.State1 = False
> > >   Me.State2 = False
> > >   ...
> > > End If 
> > > 
> > > I thought that if I were to apply the same principle to the "Northeast" 
> > > checkbox...:
> > > If (Me."Northeast") Then
> > >   Me."New England" = True
> > >   Me."Mid Atlantic" = True
> > > Else
> > >   Me."New England" = False
> > >   Me."Mid Atlantic" = False
> > > End If
> > > 
> > > ...clicking the "Northeast" would select the "New England" and "Mid 
> > > Atlantic" boxes, (which would in turn select all the states).  However, 
> > > clicking the "Northeast" checkbox only selects the "New England" and "Mid 
> > > Atlantic" boxes, NOT any of the states.  
> > > 
> > > What code am I missing?  An Afterupdate event? And would it be placed: in 
> > > the "Northeast" checkbox, "New England" checkbox, or in each state's checkbox?
0
Utf
5/16/2007 11:59:01 AM
Dave, I replied this morning but the post isn't there, let's try again....

Code in the Mid Atlantic Region checkbox called REG_NE_MA OnClick event to 
check the checkboxes State_NJ, State_NY, & State_PA when the REG_NE_MA is 
clicked:

Private Sub REG_NE_MA_Click()
If (Me.REG_NE_MA) Then
  Me.State_NJ = True
  Me.State_NY = True
  Me.State_PA = True
Else
  Me.State_NJ = False
  Me.State_NY = False
  Me.State_PA = False
End If
End Sub

--(The code for the other part of the region's checkbox, REG_NE_NE , looks 
just like that...)

Here is code in the Northeast Region checkbox called REG_NE OnClick event to 
check the REG_NE_MA and REG_NE_NE checkboxes when the REG_NE checkbox is 
checked:

Private Sub REG_NE_Click()
If (Me.REG_NE) Then
  Me.REG_NE_MA = True
  Me.REG_NE_NE = True
Else
  Me.REG_NE_MA = False
  Me.REG_NE_NE = False
End If
End Sub

 I think the solution to my problem is to be able to put code in the 
AfterUpdate Event of REG_NE to run the subs REG_NE_MA_Click() and 
REG_NE_NE_Click() ... 

I've been looking at these Access help forums but haven't been able to find 
anything like what I'm trying to do in the AfterUpdate Event...

Thanks so much for your help,
Kevin


"Klatuu" wrote:

> You can call subs and function from anywhere as long as they are within 
> scope.  If they are not,  you will get an error.
> Sorry, but the quotes do not clarify, they confuse.  If you can post the 
> exact code, perhaps we can help.
> -- 
> Dave Hargis, Microsoft Access MVP
> 
> 
> "Kevin M." wrote:
> 
> > Thanks for getting back to me.  I only had the quotation marks around the 
> > control names because I was calling them something else and was trying to 
> > make my question easier to follow...
> > 
> > I thought it was possible to call Subs in an AfterUpdate?  If, in my example 
> > below, the event New_England_Click() selects all the states' checkboxes, and 
> > the event Northeast_Click() checks the New_England checkbox, putting an 
> > afterupdate on the Northeast checkbox something very roughly along the lines 
> > of...:
> > 
> > Private Sub Northeast_AfterUpate()
> >   Sub New_England_Click()
> > End Sub
> > 
> > ...so the code in effect is 'saying':
> >  "OK, Northeast checkbox = True = New_England checkbox, now go back and run 
> > the Sub for New_England_Click(). If New_England checkbox = True, then State1 
> > = True, State2 = True, etc...."
> > 
> > Thanks again for your help.
> > 
> > "Klatuu" wrote:
> > 
> > > First, you should not be putting quotes around control names
> > > 
> > > > If (Me."Northeast") Then
> > > Should be
> > > > If (Me.Northeast) Then
> > > 
> > > Then, you are specifying regions, not states.
> > > You can't cascade the controls like that, you have to do them all by hand.
> > > -- 
> > > Dave Hargis, Microsoft Access MVP
> > > 
> > > 
> > > "Kevin M." wrote:
> > > 
> > > > I have a form with multiple checkboxes in the following format:
> > > > _X_ Northeast
> > > >   _X_ New England   _X_ State1  _X_ State2 ...
> > > >   _X_ Mid Atlantic   _X_ State5  _X_ State6 ...
> > > > 
> > > > Using the following code in the On Click Event I was able to select all the 
> > > > states in each row (i.e. all the states in New England):
> > > > If (Me."New England") Then
> > > >   Me.State1 = True
> > > >   Me.State2 = True
> > > >   ...
> > > > Else
> > > >   Me.State1 = False
> > > >   Me.State2 = False
> > > >   ...
> > > > End If 
> > > > 
> > > > I thought that if I were to apply the same principle to the "Northeast" 
> > > > checkbox...:
> > > > If (Me."Northeast") Then
> > > >   Me."New England" = True
> > > >   Me."Mid Atlantic" = True
> > > > Else
> > > >   Me."New England" = False
> > > >   Me."Mid Atlantic" = False
> > > > End If
> > > > 
> > > > ...clicking the "Northeast" would select the "New England" and "Mid 
> > > > Atlantic" boxes, (which would in turn select all the states).  However, 
> > > > clicking the "Northeast" checkbox only selects the "New England" and "Mid 
> > > > Atlantic" boxes, NOT any of the states.  
> > > > 
> > > > What code am I missing?  An Afterupdate event? And would it be placed: in 
> > > > the "Northeast" checkbox, "New England" checkbox, or in each state's checkbox?
0
Utf
5/16/2007 6:51:01 PM
REG_NE_MA_Click() looks like it should work just fine.  the parenthises 
aren't necessary, but should not change anything.  May I show you a way that 
will save you a few lines of code?

Private Sub REG_NE_MA_Click()
    Me.State_NJ = Me.REG_NE_MA
    Me.State_NY = Me.REG_NE_MA
    Me.State_PA = Me.REG_NE_MA
End Sub

So if Me.REG_NE_MA is True (Checked) so will the states.

Th other thing I would sugges would be to put breakpoints in the code were 
you think it is not executing and see what happens.


-- 
Dave Hargis, Microsoft Access MVP


"Kevin M." wrote:

> Dave, I replied this morning but the post isn't there, let's try again....
> 
> Code in the Mid Atlantic Region checkbox called REG_NE_MA OnClick event to 
> check the checkboxes State_NJ, State_NY, & State_PA when the REG_NE_MA is 
> clicked:
> 
> Private Sub REG_NE_MA_Click()
> If (Me.REG_NE_MA) Then
>   Me.State_NJ = True
>   Me.State_NY = True
>   Me.State_PA = True
> Else
>   Me.State_NJ = False
>   Me.State_NY = False
>   Me.State_PA = False
> End If
> End Sub
> 
> --(The code for the other part of the region's checkbox, REG_NE_NE , looks 
> just like that...)
> 
> Here is code in the Northeast Region checkbox called REG_NE OnClick event to 
> check the REG_NE_MA and REG_NE_NE checkboxes when the REG_NE checkbox is 
> checked:
> 
> Private Sub REG_NE_Click()
> If (Me.REG_NE) Then
>   Me.REG_NE_MA = True
>   Me.REG_NE_NE = True
> Else
>   Me.REG_NE_MA = False
>   Me.REG_NE_NE = False
> End If
> End Sub
> 
>  I think the solution to my problem is to be able to put code in the 
> AfterUpdate Event of REG_NE to run the subs REG_NE_MA_Click() and 
> REG_NE_NE_Click() ... 
> 
> I've been looking at these Access help forums but haven't been able to find 
> anything like what I'm trying to do in the AfterUpdate Event...
> 
> Thanks so much for your help,
> Kevin
> 
> 
> "Klatuu" wrote:
> 
> > You can call subs and function from anywhere as long as they are within 
> > scope.  If they are not,  you will get an error.
> > Sorry, but the quotes do not clarify, they confuse.  If you can post the 
> > exact code, perhaps we can help.
> > -- 
> > Dave Hargis, Microsoft Access MVP
> > 
> > 
> > "Kevin M." wrote:
> > 
> > > Thanks for getting back to me.  I only had the quotation marks around the 
> > > control names because I was calling them something else and was trying to 
> > > make my question easier to follow...
> > > 
> > > I thought it was possible to call Subs in an AfterUpdate?  If, in my example 
> > > below, the event New_England_Click() selects all the states' checkboxes, and 
> > > the event Northeast_Click() checks the New_England checkbox, putting an 
> > > afterupdate on the Northeast checkbox something very roughly along the lines 
> > > of...:
> > > 
> > > Private Sub Northeast_AfterUpate()
> > >   Sub New_England_Click()
> > > End Sub
> > > 
> > > ...so the code in effect is 'saying':
> > >  "OK, Northeast checkbox = True = New_England checkbox, now go back and run 
> > > the Sub for New_England_Click(). If New_England checkbox = True, then State1 
> > > = True, State2 = True, etc...."
> > > 
> > > Thanks again for your help.
> > > 
> > > "Klatuu" wrote:
> > > 
> > > > First, you should not be putting quotes around control names
> > > > 
> > > > > If (Me."Northeast") Then
> > > > Should be
> > > > > If (Me.Northeast) Then
> > > > 
> > > > Then, you are specifying regions, not states.
> > > > You can't cascade the controls like that, you have to do them all by hand.
> > > > -- 
> > > > Dave Hargis, Microsoft Access MVP
> > > > 
> > > > 
> > > > "Kevin M." wrote:
> > > > 
> > > > > I have a form with multiple checkboxes in the following format:
> > > > > _X_ Northeast
> > > > >   _X_ New England   _X_ State1  _X_ State2 ...
> > > > >   _X_ Mid Atlantic   _X_ State5  _X_ State6 ...
> > > > > 
> > > > > Using the following code in the On Click Event I was able to select all the 
> > > > > states in each row (i.e. all the states in New England):
> > > > > If (Me."New England") Then
> > > > >   Me.State1 = True
> > > > >   Me.State2 = True
> > > > >   ...
> > > > > Else
> > > > >   Me.State1 = False
> > > > >   Me.State2 = False
> > > > >   ...
> > > > > End If 
> > > > > 
> > > > > I thought that if I were to apply the same principle to the "Northeast" 
> > > > > checkbox...:
> > > > > If (Me."Northeast") Then
> > > > >   Me."New England" = True
> > > > >   Me."Mid Atlantic" = True
> > > > > Else
> > > > >   Me."New England" = False
> > > > >   Me."Mid Atlantic" = False
> > > > > End If
> > > > > 
> > > > > ...clicking the "Northeast" would select the "New England" and "Mid 
> > > > > Atlantic" boxes, (which would in turn select all the states).  However, 
> > > > > clicking the "Northeast" checkbox only selects the "New England" and "Mid 
> > > > > Atlantic" boxes, NOT any of the states.  
> > > > > 
> > > > > What code am I missing?  An Afterupdate event? And would it be placed: in 
> > > > > the "Northeast" checkbox, "New England" checkbox, or in each state's checkbox?
0
Utf
5/16/2007 7:56:02 PM
Thanks for your help.  I'm back on this project and have figured out a 
solution to the problem. Instead of an AfterUpdate event, the code that I 
didn't have was to simply "Call" the subs. Now clicking on the Northeast 
Region checkbox checks the two sub-regions AND all the underlying states.

Private Sub REG_NE_Click()
  Me.REG_NE_MA = Me.REG_NE
  Me.REG_NE_NE = Me.REG_NE
Call REG_NE_MA_Click
Call REG_NE_NE_Click
End Sub

BTW- you weren't kidding about cleaning up that code, it looks a lot better 
the way you mentioned. Thanks!

"Klatuu" wrote:

> REG_NE_MA_Click() looks like it should work just fine.  the parenthises 
> aren't necessary, but should not change anything.  May I show you a way that 
> will save you a few lines of code?
> 
> Private Sub REG_NE_MA_Click()
>     Me.State_NJ = Me.REG_NE_MA
>     Me.State_NY = Me.REG_NE_MA
>     Me.State_PA = Me.REG_NE_MA
> End Sub
> 
> So if Me.REG_NE_MA is True (Checked) so will the states.
> 
> Th other thing I would sugges would be to put breakpoints in the code were 
> you think it is not executing and see what happens.
> 
> 
> -- 
> Dave Hargis, Microsoft Access MVP
> 
> 
> "Kevin M." wrote:
> 
> > Dave, I replied this morning but the post isn't there, let's try again....
> > 
> > Code in the Mid Atlantic Region checkbox called REG_NE_MA OnClick event to 
> > check the checkboxes State_NJ, State_NY, & State_PA when the REG_NE_MA is 
> > clicked:
> > 
> > Private Sub REG_NE_MA_Click()
> > If (Me.REG_NE_MA) Then
> >   Me.State_NJ = True
> >   Me.State_NY = True
> >   Me.State_PA = True
> > Else
> >   Me.State_NJ = False
> >   Me.State_NY = False
> >   Me.State_PA = False
> > End If
> > End Sub
> > 
> > --(The code for the other part of the region's checkbox, REG_NE_NE , looks 
> > just like that...)
> > 
> > Here is code in the Northeast Region checkbox called REG_NE OnClick event to 
> > check the REG_NE_MA and REG_NE_NE checkboxes when the REG_NE checkbox is 
> > checked:
> > 
> > Private Sub REG_NE_Click()
> > If (Me.REG_NE) Then
> >   Me.REG_NE_MA = True
> >   Me.REG_NE_NE = True
> > Else
> >   Me.REG_NE_MA = False
> >   Me.REG_NE_NE = False
> > End If
> > End Sub
> > 
> >  I think the solution to my problem is to be able to put code in the 
> > AfterUpdate Event of REG_NE to run the subs REG_NE_MA_Click() and 
> > REG_NE_NE_Click() ... 
> > 
> > I've been looking at these Access help forums but haven't been able to find 
> > anything like what I'm trying to do in the AfterUpdate Event...
> > 
> > Thanks so much for your help,
> > Kevin
> > 
> > 
> > "Klatuu" wrote:
> > 
> > > You can call subs and function from anywhere as long as they are within 
> > > scope.  If they are not,  you will get an error.
> > > Sorry, but the quotes do not clarify, they confuse.  If you can post the 
> > > exact code, perhaps we can help.
> > > -- 
> > > Dave Hargis, Microsoft Access MVP
> > > 
> > > 
> > > "Kevin M." wrote:
> > > 
> > > > Thanks for getting back to me.  I only had the quotation marks around the 
> > > > control names because I was calling them something else and was trying to 
> > > > make my question easier to follow...
> > > > 
> > > > I thought it was possible to call Subs in an AfterUpdate?  If, in my example 
> > > > below, the event New_England_Click() selects all the states' checkboxes, and 
> > > > the event Northeast_Click() checks the New_England checkbox, putting an 
> > > > afterupdate on the Northeast checkbox something very roughly along the lines 
> > > > of...:
> > > > 
> > > > Private Sub Northeast_AfterUpate()
> > > >   Sub New_England_Click()
> > > > End Sub
> > > > 
> > > > ...so the code in effect is 'saying':
> > > >  "OK, Northeast checkbox = True = New_England checkbox, now go back and run 
> > > > the Sub for New_England_Click(). If New_England checkbox = True, then State1 
> > > > = True, State2 = True, etc...."
> > > > 
> > > > Thanks again for your help.
> > > > 
> > > > "Klatuu" wrote:
> > > > 
> > > > > First, you should not be putting quotes around control names
> > > > > 
> > > > > > If (Me."Northeast") Then
> > > > > Should be
> > > > > > If (Me.Northeast) Then
> > > > > 
> > > > > Then, you are specifying regions, not states.
> > > > > You can't cascade the controls like that, you have to do them all by hand.
> > > > > -- 
> > > > > Dave Hargis, Microsoft Access MVP
> > > > > 
> > > > > 
> > > > > "Kevin M." wrote:
> > > > > 
> > > > > > I have a form with multiple checkboxes in the following format:
> > > > > > _X_ Northeast
> > > > > >   _X_ New England   _X_ State1  _X_ State2 ...
> > > > > >   _X_ Mid Atlantic   _X_ State5  _X_ State6 ...
> > > > > > 
> > > > > > Using the following code in the On Click Event I was able to select all the 
> > > > > > states in each row (i.e. all the states in New England):
> > > > > > If (Me."New England") Then
> > > > > >   Me.State1 = True
> > > > > >   Me.State2 = True
> > > > > >   ...
> > > > > > Else
> > > > > >   Me.State1 = False
> > > > > >   Me.State2 = False
> > > > > >   ...
> > > > > > End If 
> > > > > > 
> > > > > > I thought that if I were to apply the same principle to the "Northeast" 
> > > > > > checkbox...:
> > > > > > If (Me."Northeast") Then
> > > > > >   Me."New England" = True
> > > > > >   Me."Mid Atlantic" = True
> > > > > > Else
> > > > > >   Me."New England" = False
> > > > > >   Me."Mid Atlantic" = False
> > > > > > End If
> > > > > > 
> > > > > > ...clicking the "Northeast" would select the "New England" and "Mid 
> > > > > > Atlantic" boxes, (which would in turn select all the states).  However, 
> > > > > > clicking the "Northeast" checkbox only selects the "New England" and "Mid 
> > > > > > Atlantic" boxes, NOT any of the states.  
> > > > > > 
> > > > > > What code am I missing?  An Afterupdate event? And would it be placed: in 
> > > > > > the "Northeast" checkbox, "New England" checkbox, or in each state's checkbox?
0
Utf
6/13/2007 7:52:00 PM
Glad I could help.

The brevity of the code is because I am lazy.  I have determined that lazy 
people are the ones who are responsible for innovation.  Hard working people 
will plug along diligently doing good work.  Lazy people, however, will try 
very hard to get out of doing work, but still get the task accomplished. :)
-- 
Dave Hargis, Microsoft Access MVP


"Kevin M." wrote:

> Thanks for your help.  I'm back on this project and have figured out a 
> solution to the problem. Instead of an AfterUpdate event, the code that I 
> didn't have was to simply "Call" the subs. Now clicking on the Northeast 
> Region checkbox checks the two sub-regions AND all the underlying states.
> 
> Private Sub REG_NE_Click()
>   Me.REG_NE_MA = Me.REG_NE
>   Me.REG_NE_NE = Me.REG_NE
> Call REG_NE_MA_Click
> Call REG_NE_NE_Click
> End Sub
> 
> BTW- you weren't kidding about cleaning up that code, it looks a lot better 
> the way you mentioned. Thanks!
> 
> "Klatuu" wrote:
> 
> > REG_NE_MA_Click() looks like it should work just fine.  the parenthises 
> > aren't necessary, but should not change anything.  May I show you a way that 
> > will save you a few lines of code?
> > 
> > Private Sub REG_NE_MA_Click()
> >     Me.State_NJ = Me.REG_NE_MA
> >     Me.State_NY = Me.REG_NE_MA
> >     Me.State_PA = Me.REG_NE_MA
> > End Sub
> > 
> > So if Me.REG_NE_MA is True (Checked) so will the states.
> > 
> > Th other thing I would sugges would be to put breakpoints in the code were 
> > you think it is not executing and see what happens.
> > 
> > 
> > -- 
> > Dave Hargis, Microsoft Access MVP
> > 
> > 
> > "Kevin M." wrote:
> > 
> > > Dave, I replied this morning but the post isn't there, let's try again....
> > > 
> > > Code in the Mid Atlantic Region checkbox called REG_NE_MA OnClick event to 
> > > check the checkboxes State_NJ, State_NY, & State_PA when the REG_NE_MA is 
> > > clicked:
> > > 
> > > Private Sub REG_NE_MA_Click()
> > > If (Me.REG_NE_MA) Then
> > >   Me.State_NJ = True
> > >   Me.State_NY = True
> > >   Me.State_PA = True
> > > Else
> > >   Me.State_NJ = False
> > >   Me.State_NY = False
> > >   Me.State_PA = False
> > > End If
> > > End Sub
> > > 
> > > --(The code for the other part of the region's checkbox, REG_NE_NE , looks 
> > > just like that...)
> > > 
> > > Here is code in the Northeast Region checkbox called REG_NE OnClick event to 
> > > check the REG_NE_MA and REG_NE_NE checkboxes when the REG_NE checkbox is 
> > > checked:
> > > 
> > > Private Sub REG_NE_Click()
> > > If (Me.REG_NE) Then
> > >   Me.REG_NE_MA = True
> > >   Me.REG_NE_NE = True
> > > Else
> > >   Me.REG_NE_MA = False
> > >   Me.REG_NE_NE = False
> > > End If
> > > End Sub
> > > 
> > >  I think the solution to my problem is to be able to put code in the 
> > > AfterUpdate Event of REG_NE to run the subs REG_NE_MA_Click() and 
> > > REG_NE_NE_Click() ... 
> > > 
> > > I've been looking at these Access help forums but haven't been able to find 
> > > anything like what I'm trying to do in the AfterUpdate Event...
> > > 
> > > Thanks so much for your help,
> > > Kevin
> > > 
> > > 
> > > "Klatuu" wrote:
> > > 
> > > > You can call subs and function from anywhere as long as they are within 
> > > > scope.  If they are not,  you will get an error.
> > > > Sorry, but the quotes do not clarify, they confuse.  If you can post the 
> > > > exact code, perhaps we can help.
> > > > -- 
> > > > Dave Hargis, Microsoft Access MVP
> > > > 
> > > > 
> > > > "Kevin M." wrote:
> > > > 
> > > > > Thanks for getting back to me.  I only had the quotation marks around the 
> > > > > control names because I was calling them something else and was trying to 
> > > > > make my question easier to follow...
> > > > > 
> > > > > I thought it was possible to call Subs in an AfterUpdate?  If, in my example 
> > > > > below, the event New_England_Click() selects all the states' checkboxes, and 
> > > > > the event Northeast_Click() checks the New_England checkbox, putting an 
> > > > > afterupdate on the Northeast checkbox something very roughly along the lines 
> > > > > of...:
> > > > > 
> > > > > Private Sub Northeast_AfterUpate()
> > > > >   Sub New_England_Click()
> > > > > End Sub
> > > > > 
> > > > > ...so the code in effect is 'saying':
> > > > >  "OK, Northeast checkbox = True = New_England checkbox, now go back and run 
> > > > > the Sub for New_England_Click(). If New_England checkbox = True, then State1 
> > > > > = True, State2 = True, etc...."
> > > > > 
> > > > > Thanks again for your help.
> > > > > 
> > > > > "Klatuu" wrote:
> > > > > 
> > > > > > First, you should not be putting quotes around control names
> > > > > > 
> > > > > > > If (Me."Northeast") Then
> > > > > > Should be
> > > > > > > If (Me.Northeast) Then
> > > > > > 
> > > > > > Then, you are specifying regions, not states.
> > > > > > You can't cascade the controls like that, you have to do them all by hand.
> > > > > > -- 
> > > > > > Dave Hargis, Microsoft Access MVP
> > > > > > 
> > > > > > 
> > > > > > "Kevin M." wrote:
> > > > > > 
> > > > > > > I have a form with multiple checkboxes in the following format:
> > > > > > > _X_ Northeast
> > > > > > >   _X_ New England   _X_ State1  _X_ State2 ...
> > > > > > >   _X_ Mid Atlantic   _X_ State5  _X_ State6 ...
> > > > > > > 
> > > > > > > Using the following code in the On Click Event I was able to select all the 
> > > > > > > states in each row (i.e. all the states in New England):
> > > > > > > If (Me."New England") Then
> > > > > > >   Me.State1 = True
> > > > > > >   Me.State2 = True
> > > > > > >   ...
> > > > > > > Else
> > > > > > >   Me.State1 = False
> > > > > > >   Me.State2 = False
> > > > > > >   ...
> > > > > > > End If 
> > > > > > > 
> > > > > > > I thought that if I were to apply the same principle to the "Northeast" 
> > > > > > > checkbox...:
> > > > > > > If (Me."Northeast") Then
> > > > > > >   Me."New England" = True
> > > > > > >   Me."Mid Atlantic" = True
> > > > > > > Else
> > > > > > >   Me."New England" = False
> > > > > > >   Me."Mid Atlantic" = False
> > > > > > > End If
> > > > > > > 
> > > > > > > ...clicking the "Northeast" would select the "New England" and "Mid 
> > > > > > > Atlantic" boxes, (which would in turn select all the states).  However, 
> > > > > > > clicking the "Northeast" checkbox only selects the "New England" and "Mid 
> > > > > > > Atlantic" boxes, NOT any of the states.  
> > > > > > > 
> > > > > > > What code am I missing?  An Afterupdate event? And would it be placed: in 
> > > > > > > the "Northeast" checkbox, "New England" checkbox, or in each state's checkbox?
0
Utf
6/13/2007 10:04:03 PM
Reply:

Similar Artilces:

Option Button
I have an option group with two option buttons - when I click one it doesn't change color so the user knows it has been selected. I don't have any different formating or colors and all the other buttons work correctly. I even tried deleting it an redoing? Any body know what's going on? Have I exceeded some kind of limit? Thanks guys in advance. Bonnie The limit of controls on a form is 755 in it's lifetime. That is rarely exceeded, but you can copy all the controls on a form and paste them to a new form, then copy and paste all the code and connect it up. Now delete...

Making attribute a checkbox
How do you make an attribute a checkbox -- donn Hi, In Customization, open the entity. Than open click on Forms and Views and open the Form. Double click on bit type of field. In new window, the second tab will be formatting. You will have option in bottom, "Control Formatting" here you can choose the desrired format. -- PLEASE do click on Yes or No button if this post was helpful or not for our feedback. uMar Khan Email for direct contact: imumar at gmail dot com "Donald" wrote: > How do you make an attribute a checkbox > -- > donn Create a bit field an...

Click, Double-Click and Run Time Error 2115
The following code works fine when executed as a double-click event. When I change it to a click event I get run-time error 2115 when in BannerUpdate (last routine in the code snippit). The text displays in the banner and I get the error. comboQuads is a combo box which is populated through the not in list event. What is happening, and how can I fix the problem? Private Sub comboQuads_Click() 'Having selected a descriptor, make the link and add the text to the banner display. Call MakeLinkRecord(rsProjects, comboQuads, rsQuadLinks, strQuadBanner) Call BannerUpdate(txtQuadBann...

Dialogsheet Checkbox to Select All Checkboxes
I am using a dialogsheet to get user input. The dialogsheet is created at runtime. The amount of checkboxes on the dialogsheet varies based on how many tabs are hidden. I would like to have a checkbox on the dialogsheet that allows users to "select all" checkboxes. Code Example: Dim SheetCount As Integer Dim CurrentSheet As Worksheet Dim PrintDlg As DialogSheet Dim cb As CheckBox Set CurrentSheet = ActiveSheet Set PrintDlg = ActiveWorkbook.DialogSheets.Add 'some code used to loop and build checkboxes not shown here If SheetCount <> 0 Then If ...

checkbox with relative reference?
I have a checkbox in E5 controlling E5. If I copy it to K11, I want it to control K11. Now, how do I give it this kind of relative reference? Thanks, Sven Sven, I take it you're going to have to do this more than a few times. I suggest you create the checkbox objects in code rather than using the Excel Control Toolbox. Add the checkboxes in the workbook open event and then you can set the attributes of each using variables. Ross "Sven Berg" <wiesel69@gmx.de> wrote in message news:060fd6fc-4258-4b48-b67b-c6909c0f2c45@8g2000hsu.googlegroups.com... >I have a check...

Right Click Context Menu
Is there a way to add items to the list? -- Guy Lapierre Forefront Business Solutions http://www.forefrontbusinesssolutions.com Guy Using VBA only. Check out this google search thread. Many good ideas for code and methods of implementing. http://snipurl.com/dr42 Gord Dibben Excel MVP On Tue, 29 Mar 2005 14:52:10 GMT, "Guy Lapierre" <guy@forefrontbusinesssolutions.com> wrote: >Is there a way to add items to the list? ...

Checkbox checked then show more checkboxes
I have added checkboxes from Control Toolbox and they seem to work fine. I just want to make one of them lets say checkbox3 to show more checkboxes when checkbox3 is marked. How do I do that? I'd add them all to exactly where I wanted them. But then have the "master" checkbox just unhide/hide the others. Option Explicit Private Sub CheckBox3_Click() Dim ShouldBeVisible As Boolean ShouldBeVisible = CBool(Me.CheckBox3.Value = True) Me.CheckBox1.Visible = ShouldBeVisible Me.CheckBox2.Visible = ShouldBeVisible Me.CheckBox4.Visible = ShouldBeVisible ...

Outlook doesn't acknowledge new e-mail until i click to a folder
hi everyone i have a user that is using MS Outlook (XP). if someone sends them an e-mail it doesn't show up until they go into their Outlook and click on to a different folder. i've seen it before but don't remember how to fix it! we're running Windows XP as well. any help would be massively appreciated. Shaun letmeoutofhere?? ;) If I understand you right, you want a new mail alert on the desktop. There are three ways, for the first two, Outlook has to be running: 1) Outlook> Tools> Options> E-mail Options> Advanced E-mail Options (for a temporary alert on ...

MS CRM should be more userfreindly (less clicks)
MS CRM should be more userfreindly, the user should be able to navigate in ms crm in just one window like in other crm apllications. The performace for the outlook client should also be better. Mail Merge Functionality is right now very poor....other applications like sage crm or slx have better solutions and they also use ms word for mail merge... Mail Merge has to be accessible from the webclient! It can not be that a customer should buy an addon for doing a mail merge. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most vot...

checkbox
How do I add checkboxes into cells in an Excel spreadsheet? Hi, Jay, First make sure you can see a checkbox by going to menu, view>toolbars> select either formatting or control box (they give you two different types of controls) then simply click on the checkbox, go to your location and click'ndrag to size it. YOu can then right click on it to set properties, assign a macro, etc. jeff >-----Original Message----- >How do I add checkboxes into cells in an Excel spreadsheet? >. > ...

Copying Checkbox Values into a different worksheet
Hi there, I'm trying to copy the value of several checkboxes to another worksheet. This works basically all fine by using the code below Sub EvaluateCB() ActiveWorkbook.Worksheets("Survey").Select Range("A1").Select d = Worksheets("Sheet1").CheckBox1.Value Selection = d End Sub But, as there are about 40 checkboxes I wonder whether there is a way to do this all automatically, i.e. by some for loop going through all the checkboxes. As I am a complete rookie in Excel I appreciate any hint / suggestions. Many thanks, Thiery You ...

Problem
My inbox is an IMAP connection, if that's of any concern. I am running 2002 XP Outlook. When I click on my mail, usually it would just highlight it and bring up the message in a preview pane. However, now it automatically opens my mail (as if I had double clicked). I figure I tripped some switch or something I overlooked. Help me out a bit here, thanks. ...

Assign Macros to Buttons from Right-Click Menu
I have an odd problem. I no longer have the option to assign macros in the right-click contex menu. When I create a custom button on an excel sheet and then enter desig mode, usually you can just record a macro, right click a button an assign a macro. I cant seem to find the option to assign macros t buttons! :confused: Any help on enabling this option in the right-click contextual men would be much appreciated. Regards -- papercli ----------------------------------------------------------------------- paperclip's Profile: http://www.excelforum.com/member.php?action=getinfo&use...

Launch jscript code when clicking on view to see all Cases
Hello I realise that this is totally going to be an unsupported customisation, but I was wondering whether anyone knew how to change the inbuilt grid form for Cases so that I could call some jscript that altered the look of the default grid used for viewing cases. Any advice or pointers appreciated. Cheers Saira Hi, Saira. Have not had a chance to try it myself, but in theory this should work. Here is the general idea: Create some *.HTM page and put it on CRM Web Server. On the page, put iframe 100% x 100%, which has it's source set to actual Cases grid. Now, you'll need t...

a problem when using a listctrl with checkbox
Hi all, I created a listctrl with checkbox (LVS_EX_CHECKBOXES) and found the checkbox could be set to checked/unchecked even by right-clicking. why? what special handling is needed for prohibiting it? thanks. bq You need to override the right click method in the control so make an extension of the listctrl class: In class wizard make a new class ListCtrlEx with base class CListCtrl. Then choose the dlg class and make a member variable for the list box say m_list and make it a control of type ListCtrlEx Then go to the message maps tab and choose class ListCtrlEx. Add a function for WM_R...

Require selection from combo on checkbox?
Hi - is it possible to set a form to require a selection from a combo if a check box is set to true? I've tried using the validation rule set to the check box name, but it doesn't work... Steve Since we're not there, we don't have any way to know HOW you "tried using the validation rule ..." If this were mine, I'd add a validation check in the form's BeforeUpdate event that ensured that there was a selection made in the combobox if the checkbox were true (and "Cancel"ed the update if there wasn't). By the way, you can make it easier f...

Adding functions to right-click menu in Outlook 2003
Is there a way to add functions to the right-click menu in Outlook 2003? Specifically, if I receive an email that contains an IP address I'd like to be able to highlight the IP address and select say ping or traceroute from the right-click menu. Is this possible with an add-in of some sort? Thanks, Seb -- Sebastian Kinnaird ...

ADO Checkbox Defaults for New Dirty Record
How do I default check boxes to False (un-ticked) with ADODB connection? and other strange behaviour... thank you the form has four (4) check boxes. When a user clicks the "New Record" button (programmed for a good UI - goes to new record, disables some navigation controls, etc...) and enters data into any control all the check boxes become ticked. I have tried • setting the defaults on the table to -1, 0, and 1. • setting the defaults on the check boxes to -1, 0, 1, and False • toggleing "retrieve defults" for the form between "Yes" and "No" • ...

Excel should have a feature just right click on a cell and get it.
I suggest Excel should have a ficility to right click on a single Cell and get its previous value. This will help to make undo more customized.. ...

unprotecting checkboxes
is there a way to allow users to check/uncheck checkboxes when the exce spreadsheet is "protected"? Thanx, -- Message posted from http://www.ExcelForum.com If your checkboxes are from the Forms toolbar, make sure that the cells they're linked to are not locked (Format/Cells/Protection, uncheck the "locked" checkbox). You should then be able to check or uncheck the checkboxes. In article <arciduca79.126qqb@excelforum-nospam.com>, arciduca79 <<arciduca79.126qqb@excelforum-nospam.com>> wrote: > is there a way to allow users to check/uncheck...

Button.Click event doesn't fire when clicking button in formView.InsertItemTemplate
I have a button in a formView.InsertItemTemplate I created a button click event and linked the button to it with the OnClick property in the aspx file. It won't fire. What could be going on? ...

Conversion difficulty with AfterUpdate code on combo
I am enquiring if there is a defect in the procedure for converting MSAccess97 developed applications to MSAccess2000. In two different cases I have found that the Afterupdate line:- DoCmd.ApplyFilter , "[Student]![StudentID]=Forms! [frmEntry]![Find a Student]" or similar, to select a particular record from a combo does not work the same in Access2000 as in Access97. While there might be a new record selected after every afterUpdate event in Access97, in Access2000 it only works the first time it is used or after the forn is re activated(?). Is there a fix for this? Or do...

CheckBox
Huston we have a problem! Is there some quick way of binding CheckBox to bool variable? it's really annoying to create lot's of onButtonPressed methods... Dymus wrote: > Huston we have a problem! > Is there some quick way of binding CheckBox to bool variable? it's > really annoying to create lot's of onButtonPressed methods... Mapping to a bool is easy but you would still have to create the OnButtonPressed method to update the bool. I.e., the bool mapping is not automatic. -- Scott McPhillips [VC++ MVP] Why? Either the buttons are all different, in which cas...

AfterUpdate Event for TextBox
I have this code for the afterupdate event on a text box that has data in it. Me.Text732 = Replace(Abs(Val([Text732])), ".", "") When I past this data 0000272400123456 into the text box, it gets rid of the 0000, becomes 272400123456 But if I past this kind of number 4223697600059898, it turns it into this 42236976000599E+15 If I take the coding away and past the 4223697600059898 number, it stays the same and doesn't get changed to the +15. Any suggestions or changes to code to fix this? Thanks! Curtis if its a text field then it shouldnt be modifying any v...

Interactive checkboxes
How can i create an interactive checkbox in excel? I want to create a form with cells that i can check or uncheck with a click of my pointer. Use the Forms toolbar. :) ************ Anne Troy VBA Project Manager www.OfficeArticles.com "courtney_lee31" <courtneylee31@discussions.microsoft.com> wrote in message news:73A2A442-92C2-467B-8B80-DB9F29D9CBD2@microsoft.com... > How can i create an interactive checkbox in excel? I want to create a form > with cells that i can check or uncheck with a click of my pointer. Like a survey form on a worksheet? If yes, you may wa...