dsum and dlookup help

Kozbot

Registered User.
Local time
Today, 08:57
Joined
Jan 16, 2013
Messages
110
I have this code
Code:
Private Sub Time_AfterUpdate()
If DSum("Time", "Timelog", "criteria = '" & Forms![Timelog Entry Form]!LotNo & "'") <> _
DLookup("RunTime", "Production and Material Usage Table", "criteria = '" & Forms![Timelog Entry Form]!LotNo & "'") + _
DLookup("Downtime", "Production and Material Usage Table", "criteria = '" & Forms![Timelog Entry Form]!LotNo & "'") Then
MsgBox "Time reported on Timelog and Production report do not match", vbOKOnly
End If
End Sub

I am getting run time error 2471. The expression you entered as a query parameter produced this error 'criteria'

What is wrong here? Also is my syntax correct when comparing the dsum value to the sum of the two dlookup values?
 
I'm guessing "criteria" is not the name of a field in the table, which it needs to be.
 
I'm guessing "criteria" is not the name of a field in the table, which it needs to be.

I'm retarded, thanks!
 
I am now having a problem with the msgbox appearing even if the comparison is equal. Anyone have any insight?
 
You should not have a field called Time because that is a reserved word: http://support.microsoft.com/kb/286335

What unit is Time measured in? if it is the DateTime field, then it is a double, and arithmetic operations on such numbers have a limited precision.

1+1=2
but, for example
1.5 + 1.5 =2.99999999999999

so to compare two double values you could

double a, double b

If abs(a-b)< some very small number Then
a is considered equal b
 
You should not have a field called Time because that is a reserved word: http://support.microsoft.com/kb/286335

What unit is Time measured in? if it is the DateTime field, then it is a double, and arithmetic operations on such numbers have a limited precision.

1+1=2
but, for example
1.5 + 1.5 =2.99999999999999

so to compare two double values you could

double a, double b

If abs(a-b)< some very small number Then
a is considered equal b

Time is a regular decimal numeric field. It is a record of total time in hours that time entry covers. I am trying to add up those entries for a lot number and compare them to another table where the runtime and downtime are recorded (for that same lot number) and look for discrepancies.
 

Users who are viewing this thread

Back
Top Bottom