right place for an event?

  • Thread starter Thread starter - Dan -
  • Start date Start date
D

- Dan -

I have a form with a text box on it. When the form loads, the text box is
already filled in and a sub runs that pulls info based on that field from a
database. If the user ever changes the value in that field to something
else as soon as they "leave" the textbox, I need to run that sub again - BUT
only if the value is different than before.

I knwo I could store the value when the user puts the focus in that textbox,
then when they leave compare the before and after and if <> then run th sub,
but is this good programming? Is this a good place to say "this is an
event" and then react to the event? the event being when before <> after?
if my thinking is headed in the right direction, how should I code it?

thank you.
 
- Dan - said:
I have a form with a text box on it. When the form loads, the text
box is already filled in and a sub runs that pulls info based on that
field from a database. If the user ever changes the value in that
field to something else as soon as they "leave" the textbox, I need
to run that sub again - BUT only if the value is different than
before.

I knwo I could store the value when the user puts the focus in that
textbox, then when they leave compare the before and after and if <>
then run th sub, but is this good programming? Is this a good place
to say "this is an event" and then react to the event? the event
being when before <> after? if my thinking is headed in the right
direction, how should I code it?

I'd store the string that has been used for the search the last time. The
next time - this can be the leave event - compare the new value to the
stored value. If changed, store the new value againd and search agin. I
wouldn't use the enter/gotfocus event but use this extra
single-value-data-layer instead.
 
ok sounds good. I've never really grasped the idea of when I create my own
events. i though this sounded like a good case for one but i guess not.
thank you.
 
Back
Top