By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,289 Members | 1,277 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,289 IT Pros & Developers. It's quick & easy.

Controlling the 'On change' event for a numeric control.

P: n/a
Hi,

I would like to be able to compare a control's new value with its old value,
whenever it is changed by a user.
The control holds a numeric value, qty_Sold, when this value changes I need
to check its validity and apply appropriate actions.
I have tried to do this using the control's 'On Change' event, and the
properties '.Value' and '.Text' to return the control's old and new values.
Unfortunately this event triggers on each character entered.
i.e.
to change an old value of 1 to a new value 234 would trigger the code
behind the event three times:
changing the “1” to a “2” - code triggered;
user must now re-enter control, position cursor to right of the “2” and
enter “3” - this triggers code;
user must now re-enter control, position cursor to right of the “3” and
enter “4” - this triggers code, for the final (and only required) time.

Clearly this isn't acceptable to the user, so how do I achieve the required
comparison only when the user has completed their change?

I don't know if this effects anything, but the control is in a datasheet sub-
form.

Many thanks,
Simon

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200803/1

Mar 3 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"SimonG via AccessMonster.com" <u41095@uwewrote in message
news:809bdb88ac39d@uwe...
Hi,

I would like to be able to compare a control's new value with its old
value,
whenever it is changed by a user.
The control holds a numeric value, qty_Sold, when this value changes I
need
to check its validity and apply appropriate actions.
I have tried to do this using the control's 'On Change' event, and the
properties '.Value' and '.Text' to return the control's old and new
values.
Unfortunately this event triggers on each character entered.
i.e.
to change an old value of 1 to a new value 234 would trigger the code
behind the event three times:
changing the "1" to a "2" - code triggered;
user must now re-enter control, position cursor to right of the "2" and
enter "3" - this triggers code;
user must now re-enter control, position cursor to right of the "3" and
enter "4" - this triggers code, for the final (and only required) time.

Clearly this isn't acceptable to the user, so how do I achieve the
required
comparison only when the user has completed their change?

I don't know if this effects anything, but the control is in a datasheet
sub-
form.

Many thanks,
Simon

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200803/1
Try using the BeforeUpdate event. Then compare MyField.Value vs
MyField.OldValue
Fred Zuckerman
Mar 3 '08 #2

P: n/a
Hi Fred,

I have tried moving the code to the BeforeUpdate event, and using the values
you describe.

This does allow the user to change the value, and does not attempt to run the
code until leaving the control. However this also causes the following error
message to appear whenever the control is changed:
"The macro or function set to the BeforeUpdate or ValidationRule property for
this field is preventing Microsoft Office Access from saving the data in the
field."
This error message also appears to stop the code performing its intended
functions, so unfortunately we do not appear to be any future forward.

Regards,
Simon

--
Message posted via http://www.accessmonster.com

Mar 3 '08 #3

P: n/a
"SimonG via AccessMonster.com" <u41095@uwewrote in message
news:809d8da67e9bc@uwe...
Hi Fred,

I have tried moving the code to the BeforeUpdate event, and using the
values
you describe.

This does allow the user to change the value, and does not attempt to run
the
code until leaving the control. However this also causes the following
error
message to appear whenever the control is changed:
"The macro or function set to the BeforeUpdate or ValidationRule property
for
this field is preventing Microsoft Office Access from saving the data in
the
field."
This error message also appears to stop the code performing its intended
functions, so unfortunately we do not appear to be any future forward.

Regards,
Simon

--
Message posted via http://www.accessmonster.com
Please provide the exact code you've set into the BeforeUpdate event. And
indicate which line is causing the error (Access highlights the line in
yellow). That will allow us to examine why you're receiving the error
message.
Fred Zuckerman
Mar 3 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.