Repost: Criteria causing a slow query

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top