Can I run code automatically between each Field being selected ?

  • Thread starter Thread starter Malcolm Hind
  • Start date Start date
M

Malcolm Hind

I have some code that displays various shapes in various sizes
depending on field contents on a form - where would I put this
code to fire automatically as each field is changed/updated ?

Thanks
 
If you want the code to fire as soon as you tab out of the control, use the
AfterUpdate event.
 
If you want the code to fire as soon as you tab out of the
control, use the AfterUpdate event.

If you want it to fire when you haven't edited the data, though,
you'll need LostFocus or OnExit, which fire whether or not you've
edited the data, while AfterUpdate fires only after an edit.

I hardly ever use the Focus and Enter/Exit events because there's
almost never a case where I need to do something when a control has
not been updated.

(and, yes, I know the OP asked about fields being updated, but I
thought it was important to answer the broader question, since the
way Arvin worded it would be misleading absent the context of the
original question)
 
David W. Fenton said:
If you want it to fire when you haven't edited the data, though,
you'll need LostFocus or OnExit, which fire whether or not you've
edited the data, while AfterUpdate fires only after an edit.

I hardly ever use the Focus and Enter/Exit events because there's
almost never a case where I need to do something when a control has
not been updated.

(and, yes, I know the OP asked about fields being updated, but I
thought it was important to answer the broader question, since the
way Arvin worded it would be misleading absent the context of the
original question)

I do try to answer questions as posted, although I miss sometimes. LostFocus
and OnExit can also work if there are edits or not, by checking to see
whether data has changed (using the OldValue property) but in most cases it
is much easier and less complex to just use AfterUpdate if you are looking
to just work on changed/updated values.
 
Back
Top