I have:
1) Table1 containing fields: ID, Name, Wage, WorkingHours, Date,
2) Form1 containing: txtDate, txtCO
I must create a Function that Sum the Wage from last 5 days.
Exp1 = DSUM([Wage],[Table1],Where Date <[Forms]![Form1]![txtDate]-5)
But I must do it in SQL (VBA).
I can't undesternd how to VBA...
1) Table1 containing fields: ID, Name, Wage, WorkingHours, Date,
2) Form1 containing: txtDate, txtCO
I must create a Function that Sum the Wage from last 5 days.
Exp1 = DSUM([Wage],[Table1],Where Date <[Forms]![Form1]![txtDate]-5)
But I must do it in SQL (VBA).
I can't undesternd how to VBA...
Code:
Function WA(CO) As Integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb
If CO>0 Then
strSQL = "SELECT Sum(Wage) AS [SumOfWage] FROM [Table1] WHERE Date < Forms![Form1]![txtData]-5
Set rs = db.OpenRecordset(strSQL)
WA= rsTot("SumOfWage")
rs.Close
db.Close
Set db = Nothing
Else
WA = 0
EndIf
Exit Function