Re-calculate when a value is changed...but...

D

Duncan Edment

Strange subject, to go with an equally strange question!

On my form, I record Date, Start Time & End Time. If any of these values
changes, I want to re-calculate--if required--the values held in three
calculated controls. Seems easy enough...just put a call to Form_Current--where
all my calculations are--in the AfterUpdate and hey presto. However, this wont
work.

You see, what the calculations do is step through all records in the database
for the specified employee, and total up three duration values. If I change,
for example, the StartTime, the calculations will be based upon the "old
StartTime", as held in the database and not the new StartTime as held in the
control. If I change the display to the next record, the updated record gets
saved and the calculation is now based upon the newly entered StartTime and so
the values in the three calculated controls will change.

So, what I want to know is, if a value is changed in one of these three fields:

1. Is it advisable to save the record to the database and if so how?
2. If not advisable to do 1, how do I get around this problem?

Many thanks for your help.

Duncan

--
Newsgroups are like one big sandbox that all of us
UseNet kiddies play in with peace & harmony.

Spammers, Cross-Posters, and Lamers are the
people that pee in our big sandbox.
 
B

Byron

Try placing the following in the AfterUpdate event of
your controls that you want to recalculate:
If Me.Dirty Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70
End If

HTH
Byron
 
J

John Vinson

Try placing the following in the AfterUpdate event of
your controls that you want to recalculate:
If Me.Dirty Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70
End If

Or, equivalently and less cryptically,

If Me.Dirty Then
DoCmd.RunCommand acCmdSaveRecord
End If


John W. Vinson[MVP]
(no longer chatting for now)
 

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

Top