PLEASE Help ME,Get a calculated field on a form to write to the same field on a table (1 Viewer)

L

lcalcagni

Guest
I have several calculated fields on a form, with the same name to the table. I need to get the calculation to write to the table. I have tried queries with no success. Maybe I am writing them wrong. I have tried an action macro with no success. Please help!!!!
 

HL

Registered User.
Local time
Today, 12:52
Joined
Feb 13, 2001
Messages
19
I had this problem the other week, when I was trying this statement (=DateDiff("n",[Equipment Stop Time],[Equipment Start Time]) in an unbound text called Actual Down Time to a field name in a table called Actual Down Time without any success.

So I set up a bound text box [Actual Down Time]

Then I used an macro.

I set the macro up like this: Action = SetValue , Item = [Forms]![FrmDowntime]![Actual Dowm Time]
Expression = =DateDiff("n",[Equipment Stop Time],[Equipment Start Time])

Then I set the form up by clicking on the properties for [Equipment Stop Time] and [Equipment Start Time]) and setting the after update to the macro and this is working fine.

So My calculation's for working out downtime between two times is correct an it is sending the information to the table.

I hope this little bit of information has pointed you in the right direction.

HL
 

Rich@ITTC

Registered User.
Local time
Today, 12:52
Joined
Jul 13, 2000
Messages
237
Hi lcalcagni and HL

I always wonder why database designers want to save calculated data to another field/table. Good relational database design prevents the necessity of storing the same information twice (which is in effect what you are doing - you have all the parts which you bring together in your calculated field - and that is always available and then you have your duplicated stored version). Have a look at these two postings on similar topics:

<A HREF="http://www.access-programmers.co.uk/ubb/Forum2/HTML/000570.html" TARGET=_blank>www.access-programmers.co.uk/ubb/Forum2/HTML/000570.html

</A> www.access-programmers.co.uk/ubb/Forum2/HTML/000601.html

HTH

Rich Gorvin

[This message has been edited by Rich@ITTC (edited 03-15-2001).]
 

archiecone

Registered User.
Local time
Today, 12:52
Joined
Jan 30, 2001
Messages
20
You can do it in Visual Basic as well.

Public Sub name()
Dim x1 As Database
Dim rs1 As Recordset
Set x1 = CurrentDb()
Set rs1 = x1.OpenRecordset("tablename")
With rs1
.MoveFirst
While Not .EOF

calculation or if statement here
rs1.Edit
rs1.Fields("fieldname") =variable
rs1.Update
Wend
End With

Hope this helps you

[This message has been edited by archiecone (edited 03-15-2001).]
 

Users who are viewing this thread

Top Bottom