Counter Help (1 Viewer)

mapat

Registered User.
Local time
Today, 08:49
Joined
Feb 2, 2007
Messages
176
hello,

I have "txtboxA" and "txtboxCount" on a form.
When "txtboxA" is updated to a different value (number) I would like "txtboxCount" to save this value, meaning that "txtboxCount" would basically be a counter (it will be adding up all the values of "txtboxA"). How would I do this? I want "txtboxCount" to show the latest value as soon as "txtboxA" is updated. How would I do this?

Thank you very much
 

Brian1960

Brian1960
Local time
Today, 16:49
Joined
Aug 13, 2004
Messages
141
Use Events

On the txtboxA use an event after change and run code

Code:
If isNumeric(txtboxA ) and txtboxA >0 then
  txtBoxCount = txtBoxCount + txtboxA
  Me.refresh ' this may be me.requery
End if
 

CEH

Curtis
Local time
Today, 10:49
Joined
Oct 22, 2004
Messages
1,187
In control source of txtboxCount... put =Sum([txtboxA])
And on the BeforeUpdate event of txtboxA put Me.requery
 

Brian1960

Brian1960
Local time
Today, 16:49
Joined
Aug 13, 2004
Messages
141
Counter

The code I sent was for unbound text boxes.
If you add the code to the LostFocus event of the txtBoxA it works fine.
 

Brian1960

Brian1960
Local time
Today, 16:49
Joined
Aug 13, 2004
Messages
141
Counting

Okay so we now have two bound controls and they multply to give third.
If the third box is bound then why? We then have a fourth control as a counter (bound?).

Is this right?
4 controls on a form.
The first two are bound to a table.

txtBox1
txtBox2

This third can be bound as well and updates on either of the first two being changed (beforeUpdate Event!)
txtBoxA = txtbox1 x txtBox2

So what is this for? Is it bound?
txtBoxCount

If you use the code I gave you in either of the first two controls. This will keep adding the results, but when you open the form it will reset to its intial value.

It might help if you try to explain what you are doing.

Brian
 

Users who are viewing this thread

Top Bottom