This topic is locked
[SOLVED]

 Insert and calculate in another table

12/14/2012 3:00:35 PM
ASPRunnerPro General questions
M
mitzi author

I have two tables:
WorkedHrs(directly below) and calcalendar (where the data are actually entered initially)
SELECT ID,

EmployeeName,

Address,

DateField,

TimeField,

EndTime,

DATEDIFF("n", [TimeField], [EndTime])/60 AS TotalHrs,

OwnerID,

EmployeeRate,

*[EmployeeRate][TotalHrs] AS Earnings

FROM WorkedHours
This is what is supposed to happen:
As soon as data are entered in the calcalendar table the following are inserted into "workedhrs table"
no problems here as I used brilliant code supplied by the asprunner in the events as follows:
'****
Insert a record into another table ****

dim dal_table

set dal_table=dal.Table("WorkedHours")

dal_table.DateField=values("DateField")

dal_table.EmployeeName=values("EmployeeName")

dal_table.Address=values("Theme")

dal_table.TimeField=values("TimeField")

dal_table.EndTime=values("EndTime")


dal_table.OwnerID=values("OwnerID")

dal_table.EmployeeRate=values("EmployeeRate")

dal_table.Add()
the resulting table correctly displays:
StarTime, end time, correctly calculate numbers of hours worked, displays the EmployeeRate BUT
it does not calculate the Earnings
what am I doing incorrectly?

admin 12/14/2012

Instead of [TotalHours] you need to use the underlying expression i.e.

[EmployeeRate]*(DATEDIFF("n", [TimeField], [EndTime])/60) AS Earnings
M
mitzi author 12/16/2012

Thank you, you can mark it as solved.