Click vs AfterUpdate events

  • Thread starter Thread starter Martin Walke
  • Start date Start date
M

Martin Walke

Hi all,

Can someone explain to me what's the difference between the click and
afterupdate events on an unbound checkbox on a form (access 2003), please?

I just want to place a checkbox on a form and enable/disable a text box
(both unbound) but the code behind the click event doesn't run but putting
code behind the AfterUpdate event does. So what gives?

TIA
Martin
 
Martin Walke said:
Hi all,

Can someone explain to me what's the difference between the click and
afterupdate events on an unbound checkbox on a form (access 2003),
please?

I just want to place a checkbox on a form and enable/disable a text
box (both unbound) but the code behind the click event doesn't run
but putting code behind the AfterUpdate event does. So what gives?

For a check box, there's not much practical difference between the
events. In general, the Click event fires whenever a control receives a
mouse click, while the AfterUpdate event fires when the control's value
is updated. For a check box, clicking on it changes its value, so both
fire. For other controls, clicking on the control doesn't necessarily
change the value.

I would expect both events to fire when you click on the check box or
its attached label; first AfterUpdate, then Click. I just tested this,
and that's what happens for me. Are you sure the OnClick event property
of your check box is set to "[Event Procedure]"?
 
Ah! See, there's that snippet of info that I missed. I'm a long time VB
programmer who's been asked to modify some VBA behind an Access DB so I
simply added a check box and added the code to the click event but.....
didn't make the connection of linking the event to the code. Of course, VB6
does that pretty much automatically (unlike a lot of other languages) and it
simply slipped from my view.

Many thanks, Dirk. I thought there couldn't be much difference in the long
run.

Martin

Dirk Goldgar said:
Martin Walke said:
Hi all,

Can someone explain to me what's the difference between the click and
afterupdate events on an unbound checkbox on a form (access 2003),
please?

I just want to place a checkbox on a form and enable/disable a text
box (both unbound) but the code behind the click event doesn't run
but putting code behind the AfterUpdate event does. So what gives?

For a check box, there's not much practical difference between the
events. In general, the Click event fires whenever a control receives a
mouse click, while the AfterUpdate event fires when the control's value
is updated. For a check box, clicking on it changes its value, so both
fire. For other controls, clicking on the control doesn't necessarily
change the value.

I would expect both events to fire when you click on the check box or
its attached label; first AfterUpdate, then Click. I just tested this,
and that's what happens for me. Are you sure the OnClick event property
of your check box is set to "[Event Procedure]"?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Martin Walke said:
Ah! See, there's that snippet of info that I missed. I'm a long time
VB programmer who's been asked to modify some VBA behind an Access DB
so I simply added a check box and added the code to the click event
but..... didn't make the connection of linking the event to the code.
Of course, VB6 does that pretty much automatically (unlike a lot of
other languages) and it simply slipped from my view.

In fact, Access usually does a pretty good job about this, too.
Normally, if you enter (or paste) a properly defined event procedure in
the form's code module, Access will make the connection and set the
event property. However ... sometimes it doesn't. And if you change
the name of an existing procedure, it doesn't.
Many thanks, Dirk. I thought there couldn't be much difference in the
long run.

You're welcome.
 
Back
Top