Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving math results in a table

Status
Not open for further replies.

lrumd

Technical User
Sep 5, 2002
25
US
I need to do some simple math with time data but it becomes very complicated when many of these results have to be compared using logical statements (If...Then.., etc.)

I was told in the past that there is no need to save the results of my calculations "because the raw data is already there" and "you need to learn how to program well from the beggining" etc. I understand this but in order to know for sure that my formulas are working well, and that I am doing things right I do need to save the results in a table. Please help me out here. And please don't tell me "you don't have to..." I don't need to be elegant on my programming (yet)

OK. I have:

tblHoursWorked
TimeIn
TimeOut
Lunch

I would like to calculate
TimeWorked =[TimeOut]-[TimeOut]-Nz([Lunch],0)

It works if I enter the formula in a textbox on a form. But how do I save that info on another table, say

tblSummary
HoursWorked

Thanks a lot

Luis
 
Sorry, I meant:

TimeWorked =[TimeOut]-[TimeIn]-Nz([Lunch],0)

Luis [atom]
 
i'm not sure how to do this through design view, but in sql view, open the query and look at the sql

change

select .... (all your calculations)
from yourtable

to

select .... (all your calculations)
into newtable
from yourtable

and this will save your result set into newtable

rudy
 
OK.........(huge sigh)

You need that field to exist in the underlying table/query.

Open the form in Design View
Go To View- Field List
Drag that field somewhere on your form
Leave your calculated control in place.
Now go to View-Code
Paste this:

Sub Form_BeforeUpdate(Cancel as Integer)
Me("HoursWorked") = [TimeOut]-[TimeIn]-Nz([Lunch],0)
End Sub

That will store your calculated result in the table.
And you will blame me for this when you'll get into trouble, right?


[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
On the assumption that calculating as needed really is too burdendsome, I'd deal with this problem by using an Excel spreadsheet and linking to it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top