afterupdate event

  • Thread starter Thread starter Kate
  • Start date Start date
K

Kate

Hey,
so i have two text boxes which have numbers in them.
I have a third text box which is, say the sum of the two numbers. I
don't want the third text box to be a calculated control because i
want to use it elsewhere (and i want the number to appear immediately
when you change one of the first two).
Therefore I had a macro set up on the both the first 2 text boxes
which sets the value of the third.
I have this macro set up as an afterupdate, but it only works after i
update one of hte numbers, not the other - it seems whichever comes
first in the tab order is the one that counts...
Why is this?
Also, the setvalue property in the macro used to work fine in the 2003
access, but it doesn't appear in 2007 as an option - the only reason i
can even use it, is because this macro was created on 2003. What are
you supposed to use instead?

Thanks
Kate
 
You will need to use the AfterUpdate event of *both* the controls that could
change the value, e.g.:
Private Sub Text1_AfterUpdate()
Me.Text3 = Me.Text1 + Me.Text2
End Sub
Private Sub Text2_AfterUpdate()
Call Text1_AfterUpdate
End Sub

In Access 2007, in macro design, click Show All Macros on the ribbon.

I'm not convinced that storing the total is the right approach here. Instead
of storing Text3 in a table, you could create it like this in a query:
Text3: [Text1] + [Text2]
Then use this query as the RecordSource for your form, and ti will
automatically update without needing any code or macro. More info in:
Calculated Fields
at:
http://allenbrowne.com/casu-14.html
 
possible alternative?

MyTable
WhatEverId (counter)
n1 (number)
n2 (number)

SELECT n1, n2, n1 + n2 AS n1_Plus_n2
FROM MyTable
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

AfterUpdate 9
AfterUpdate unreliable? 5
dlookup 2
Autoupdate calc in form 1
clear a combo box with a macro 1
Click vs AfterUpdate events 3
Shape Arrays VBA 0
AfterUpdate Make Visible 5

Back
Top