FastEddieB
Programmer
In MS Access, I have a large group of queries that use a module I wrote called IsInDay. We collect data by shifts, but our 2nd shift runs a couple of hours after midnight, so when you query data using a shift and a date, it misses the entries after midnight.
The IsInDay module, looks at the time stamps of each entry and then gives them a "Shiftdate" value of the date before.(Anything between midnight and 3am)
Here is the code:
Option Compare Database
Public Function IsInDay(ByVal pdtDate As Date) As Boolean
Dim dtStart As Date
Dim dtEnd As Date
dtStart = DateValue(pdtDate) + TimeValue("3:00AM"
dtEnd = DateValue(DateAdd("d", 1, pdtDate)) + TimeValue("3:00AM"
IsInDay = ((pdtDate >= dtStart) And (pdtDate <= dtEnd))
End Function
Public Function ShiftDate(ByVal pdtDate As Date, _
ByVal pdtTime As Date) As Date
Dim dtStart As Date
If pdtTime < TimeValue("3:00AM" Then
ShiftDate = DateAdd("d", -1, pdtDate)
Else
ShiftDate = pdtDate
End If
End Function
This works great in Access and gives us exactly what we are looking for.
Now, I am attempting to create sreadsheets that automatically update in Excel. When I use MS Query to set up the transfer of data, and I select a query to use, I get the following error message.
"Undefined Function 'ShiftDate' in Expression"
I tried inserting a copy of this module, as a module in the spreadsheet, and this still doesn't work. Does anyone have any clues. Am I doing something wrong?
Thank ahead of time for any and all suggestions
The IsInDay module, looks at the time stamps of each entry and then gives them a "Shiftdate" value of the date before.(Anything between midnight and 3am)
Here is the code:
Option Compare Database
Public Function IsInDay(ByVal pdtDate As Date) As Boolean
Dim dtStart As Date
Dim dtEnd As Date
dtStart = DateValue(pdtDate) + TimeValue("3:00AM"
dtEnd = DateValue(DateAdd("d", 1, pdtDate)) + TimeValue("3:00AM"
IsInDay = ((pdtDate >= dtStart) And (pdtDate <= dtEnd))
End Function
Public Function ShiftDate(ByVal pdtDate As Date, _
ByVal pdtTime As Date) As Date
Dim dtStart As Date
If pdtTime < TimeValue("3:00AM" Then
ShiftDate = DateAdd("d", -1, pdtDate)
Else
ShiftDate = pdtDate
End If
End Function
This works great in Access and gives us exactly what we are looking for.
Now, I am attempting to create sreadsheets that automatically update in Excel. When I use MS Query to set up the transfer of data, and I select a query to use, I get the following error message.
"Undefined Function 'ShiftDate' in Expression"
I tried inserting a copy of this module, as a module in the spreadsheet, and this still doesn't work. Does anyone have any clues. Am I doing something wrong?
Thank ahead of time for any and all suggestions