G
Gargamil
Greetings
I am trying to search a table of about 17,000 records for combination
dates and equipment numbers in VBA. I am trying to debug the code because
the lookups only return the first of the records against a given EqNum. It
seems the date part of the function is ignored in the code. Granted the
code is not fully formed but what am I missing here??
The dates are in the table are in Australian format dd/mm/yyyy - hence
the format function below - although that did not seem to solve the problem.
Function LookupMeterReading() '(EqNum, SampleDate)
EqNum = "714-R/HFDRV"
SampleDate = "7/11/2006"
Debug.Print DateValue(SampleDate), Format(SampleDate, "mm/dd/yyyy")
criteria = "([Date] = #" & DateValue(SampleDate) & "#) and ([EqNum] =
'" & EqNum & "')"
MeterRead = DLookup("[MeterReading]", "HSOILSMP", criteria)
AlarmGrop = DLookup("[AlarmGroupID]", "HSOILSMP", criteria)
LoadDate = DLookup("[LoadDate]", "HSOILSMP", criteria)
Debug.Print MeterRead, AlarmGrop, LoadDate, criteria
End Function
I am trying to search a table of about 17,000 records for combination
dates and equipment numbers in VBA. I am trying to debug the code because
the lookups only return the first of the records against a given EqNum. It
seems the date part of the function is ignored in the code. Granted the
code is not fully formed but what am I missing here??
The dates are in the table are in Australian format dd/mm/yyyy - hence
the format function below - although that did not seem to solve the problem.
Function LookupMeterReading() '(EqNum, SampleDate)
EqNum = "714-R/HFDRV"
SampleDate = "7/11/2006"
Debug.Print DateValue(SampleDate), Format(SampleDate, "mm/dd/yyyy")
criteria = "([Date] = #" & DateValue(SampleDate) & "#) and ([EqNum] =
'" & EqNum & "')"
MeterRead = DLookup("[MeterReading]", "HSOILSMP", criteria)
AlarmGrop = DLookup("[AlarmGroupID]", "HSOILSMP", criteria)
LoadDate = DLookup("[LoadDate]", "HSOILSMP", criteria)
Debug.Print MeterRead, AlarmGrop, LoadDate, criteria
End Function