473,385 Members | 1,869 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,385 software developers and data experts.

Which form event fires after any field is updated?

91
I'm trying to find which event fires after any of the textboxes are updated on my form. I have an average field, and any time a user changes any one of the 20 textboxes I want it to update.

Or, is there a better way to do this?



I have tried Form_AfterUpdate, Form_DataChange but no luck
Jul 23 '10 #1
8 20890
NeoPa
32,556 Expert Mod 16PB
Strangely, the Help system seems to know nothing of the Form_AfterUpdate event. Assuming you've tried that though, I can only assume it doesn't do what you require.

In your shoes I'd put AfterUpdate event procedures on each of your 20 TextBoxes that simply call the procedure that sets up your average value.
Jul 23 '10 #2
Stewart Ross
2,545 Expert Mod 2GB
Hi. The form's AfterUpdate event will only fire after you move away from the current edited record - by saving it, moving focus to another record or form, or by closing the form.

As you need to update your computed field every time one of the contributing textboxes has been updated you will indeed need to use the AfterUpdate event of each textbox to call your requery method, as NeoPa has advised.

For a full description of the form's afterupdate event, see this MSDN reference item.

-Stewart
Jul 24 '10 #3
missinglinq
3,532 Expert 2GB
An alternate method would be to
  1. Create a Query based on your underlying Table
  2. Create a Calculated field in the Query, using your expression for calculating the average
  3. Base your Form or Report on the Query
Generic code for the calculated field would be

AverageField:([Field1] + [Field2] + [Field3])/[Field4]

Note the square brackets around each field name.

Then in your form or report use AverageField where the average is needed. It will be automatically re-calculated anytime any of the twenty fields are changed.

Linq ;0)>
Jul 24 '10 #4
OldBirdman
675 512MB
I think the answers given miss the original question.

There are 20 textboxes, txt01, txt02, ... txt20. Assume each has the value of 1. Therefore
Expand|Select|Wrap|Line Numbers
  1. txtAvg = (txt01 + txt02 + ... + txt20) / 20
will assign a "1" into txtAvg. If txt14 is changed to 21, then txtAvg needs to be "2" as soon as txt14 is changed. Now if the user changes txt08 to 41, txtAvg needs to change to "4".
So the question is: "Where is the above line of code best put so that whenever any of the textboxes txt01, txt02, ... is changed, txtAvg shows the correct value?"
The form's On Dirty Event only fires once, after the first change. It does not fire on subsequent changes. There is no On Dirtier Event.
I would probably put the above logic in a function, and then for the On Change or After Update event for each of the 20 textboxes call the function.
The function could be called from the form's On Key Press function and be more dynamic, but this requires knowing which control has the focus (is being changed), and using .Text or .Value as necessary. This can get messy if the user makes a typo.
Jul 24 '10 #5
OldBirdman
675 512MB
I missed the suggestion by NeoPa that is the same as my solution, an event on each of the textboxes. Sorry NeoPa.
Jul 24 '10 #6
NeoPa
32,556 Expert Mod 16PB
There seems to be some confusion here OB.

I haven't tested Linq's solution myself, but if it works it certainly seems as if it would fit the requirements perfectly, doing everything as you've explained it needs to do.

This is also true of the suggestion in my post (as clarified somewhat by Stewart). In fact, your suggestion to use the AfterUpdate event procedure of each of the twenty TextBoxes to call the function that does the working out matches what I suggested in my post.

Where you suggest options of using the Change event, or even the KeyPress event, I have to differ. These I feel would be quite inappropriate for this as the average value would change while the operator was typing in their value. A value of 4 should never be used to determine the average, yet this would occur in that scenario before they'd finished typing in 41.

PS. Now I see post #6 :D
Jul 24 '10 #7
OldBirdman
675 512MB
My apologies to Linq as his solution does work. I have now tested it. And I learned something about how dynamic queries are after they have 'run'. Not sure I understand, though.
As NeoPa's Post#2 suggestion is the same as mine, and as the original question clearly states "I'm trying to find which event fires after any of the textboxes are updated on my form.", I have nothing to add.
Jul 24 '10 #8
FishVal
2,653 Expert 2GB
Just my 5c

Regards,
Fish
Jul 24 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: JayDee | last post by:
After a user enters data into a field, I need to populate other controls on the form, based on the user entry. I have to use either Leave, Validating or Validated, and I take it I can't use...
5
by: Maxine G | last post by:
I have two forms, a menu and a data entry form. The entry form is bound to a query against linked SQL server tables. In the deactivate event, I have some code which asks the user if they want to...
19
by: Heidi Hundåla | last post by:
Hi ! I have a Wep App in C#. Page_Unload fires after Page_Load, and it seems totally unreasonable when you want to use this event when you _leave_ the page. In my project we wanted to use...
5
by: Mike Salter | last post by:
I created a page that reads a DB for questions and possible answers (usuallyYes/No). I create a panel for each group of questions, and add a panel for each question to the Group panel. To the...
9
by: foo | last post by:
Hello, What event will fire when a user types data into a field and then the field loses the focus but does not fire when a field is filled programatically? I don't want the event to run when...
5
by: Keith-Earl | last post by:
I have a simple combo box on a VB.NET 1.0 Windows form. The SelectedValueChanged event fires constantly during form load and whenever the tab that houses the cbo is reselected. I have tried the...
6
by: Jeff User | last post by:
Hi I have a WebControls.DropDownList. autoPostBack is set to true. I have code (C#) in the event procedure in the code behind and it works fine. OK, now my problem is this: While in the...
3
by: doctorle | last post by:
I'm surprised that the Current event of forms always fires twice (Access XP). I have quite a lot of processing done in the current event, how to make the code run just once? Thanks
14
by: teddysnips | last post by:
WINDOWS FORMS I've a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user...
3
by: Drex10 | last post by:
I have an event that occurs within a user control. The event is for a dropdownlist within the user control which fires when the selected item changes. This user control is created dynamicaly...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.