473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
3 2240
"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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Robert W. | last post by:
I have a 'Controller' object that manages the interaction between its two children: a Form and a DataObject. I've written specialized code in the Controller to control how the Form updates the...
2
by: Tubs | last post by:
I am trying to use data binding to avoid having to write event handlers everywhere for my data transfer from controls to data source and all is working well except, i have a condition i would like...
2
by: Wouter van Teijlingen | last post by:
Dear Readers, I was reading about how to control the COM and LPT port using VB .NET. I've found a lot of information, and it was very useful to me. I found an example program on the site of...
4
by: LCAdeveloper | last post by:
Help! Another newbie question I'm afraid. I have a toolbar on an MDI form, which I can control OK to produce a child form. When the child form is active, the appropriate MDI parent form toolbar...
3
by: Adriana Camargo | last post by:
Hi I have to change automatically the text inside a textbox. I need to add thousand separator when I am writting in the textbox. I am using TextChanged event and when I insert a new number, i...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
1
by: Martin | last post by:
Hi, I have a FormView control with a MultiView control within it's EditItemTemplate (because using a Wizard doesn't maintain two way data binding - MS confirmed bug). Any how, I have the...
5
by: sklett | last post by:
I know that Panel (and most of it's derivitives) don't raise keyboard events. I *really* need to catch keyboard events though so I've been googling the topic and have found quite a few...
5
by: Pascal | last post by:
Hello This is, below, a piece of code that I have a problem with: In the program (french description here http://www.scalpa.info/carre_install_clickonce/aide_carre.htm) a number is generated...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.