473,761 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.c om
http://www.accessmonster.com/Uwe/For...ccess/200803/1

Mar 3 '08 #1
3 2260
"SimonG via AccessMonster.c om" <u41095@uwewrot e in message
news:809bdb88ac 39d@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.c om
http://www.accessmonster.com/Uwe/For...ccess/200803/1
Try using the BeforeUpdate event. Then compare MyField.Value vs
MyField.OldValu e
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.c om" <u41095@uwewrot e in message
news:809d8da67e 9bc@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
1266
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 DataObject and vice-versa. Normally after the user changes the value of a control, the DataObject is instantaneously updated (via code in the Controller). But I'm having problems when say the user enters text into a textbox and then immediately...
2
1305
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 to place on the value before i let it go through. I have built an expression evaluator to determine when something is valid versus invalid. My problem is that when i trap the format event of the data binding, i can get to the value before it...
2
5158
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 Microsoft. You can find it overhere: http://www.microsoft.com/downloads/details.aspx?FamilyID=075318ca-e4f1-4846-912c-b4ed37a1578b&DisplayLang=en I did found a lot about the RS232 port on the Internet, but i haven't found the same amount of...
4
2772
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 button properties are set as follows: .pushed=true and .enabled=false. My problem is how do I set the reverse conditions when I close this child form? I have tried putting (in the Exit button click event) Toolbar1.Buttons(6).Pushed=False...
3
5187
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 have a function that formats the complete text with thousand separator. For example, if textbox1 content is 1,234 and i added a number 5 after number 1, the result must be 15,234.
8
2185
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 answered... In 1.1 we always did our own myDataAdapter.fills and we liked that control for lots of good reasons. Now the new DataSource (or is it a TableAdapter:Dataset) automatically fills the Gridview. How can we control that fill? In a...
1
3241
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 requirement to save my data every time I change view of my MultiView control. So I call FormView.UpdateItem() This works fine, except for having the side effect of putting the
5
6124
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 suggestions. The one suggestion I've found that makes the most sense isn't working for me and after this most recent failure I'm really at a loss! ;0) I'm overriding WndProc and checking the Message.Msg property for the WM_KEYUP message. If anyone has...
5
1412
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 in the interval given by the value of nudNumMin and nudNumMax. In the user interface can be created several "projects" appearing in a listbox, which each have their characteristics. By clicking on the project in the listbox, controls must display...
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9925
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9811
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8814
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, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.