S
Scott J.
This is a repost of my problem:
No Problem. Here is the Function (The SQL statement is what I was referring
to as Query2):
Function GetDateDiff(Machine As Variant, daDate As Date)
On Error Resume Next
Dim MyDB As Database, MyRec As Recordset, MyLargeDate As Variant
Set MyDB = CodeDb
Set MyRec = MyDB.OpenRecordset("SELECT
OperatorPMandOilChangeTable.MachineNumber,
OperatorPMandOilChangeTable.ServiceDate FROM OperatorPMandOilChangeTable
Where [MachineNumber] = """ & Machine & """ AND [ServiceDate] <= #" & daDate
& "# ORDER BY OperatorPMandOilChangeTable.MachineNumber,
OperatorPMandOilChangeTable.ServiceDate DESC")
If Not MyRec.EOF Then
MyLargeDate = MyRec!ServiceDate
MyRec.MoveNext
GetDateDiff = DateDiff("d", MyRec!ServiceDate, MyLargeDate)
End If
End Function
Query1 has the following fields and criteria:
MachineNumber; RecordNumber; ServiceDate (Criteria references two controls
on a form); WeeklyPMCheck (Criteria: True); Late:
GetDateDiff([MachineNumber],[ServiceDate]) (Criteria: <=10)
Does that help??
Scott J.
No Problem. Here is the Function (The SQL statement is what I was referring
to as Query2):
Function GetDateDiff(Machine As Variant, daDate As Date)
On Error Resume Next
Dim MyDB As Database, MyRec As Recordset, MyLargeDate As Variant
Set MyDB = CodeDb
Set MyRec = MyDB.OpenRecordset("SELECT
OperatorPMandOilChangeTable.MachineNumber,
OperatorPMandOilChangeTable.ServiceDate FROM OperatorPMandOilChangeTable
Where [MachineNumber] = """ & Machine & """ AND [ServiceDate] <= #" & daDate
& "# ORDER BY OperatorPMandOilChangeTable.MachineNumber,
OperatorPMandOilChangeTable.ServiceDate DESC")
If Not MyRec.EOF Then
MyLargeDate = MyRec!ServiceDate
MyRec.MoveNext
GetDateDiff = DateDiff("d", MyRec!ServiceDate, MyLargeDate)
End If
End Function
Query1 has the following fields and criteria:
MachineNumber; RecordNumber; ServiceDate (Criteria references two controls
on a form); WeeklyPMCheck (Criteria: True); Late:
GetDateDiff([MachineNumber],[ServiceDate]) (Criteria: <=10)
Does that help??
Scott J.