TraciAnn,
Implement these four steps and it should work by date.
1. Make a backup of your current mdb file.
This is because your present version is accomplishing your original goal and
you do not want to lose that in case of a disaster.
2. Load tblMilRates with the following data:
1/1/2006 - 0.445
1/1/2007 - 0.485
1/1/2008 - 0.505
7/1/2008 - 0.585
1/1/2009 - 0.55
3. Replace the function GetMilRate with the following:
(Probably should use a copy and paste)
Public Function GetMilRate(Optional TravelDate As Date) As Currency
On Error GoTo Err_GetMilRate
GetMilRate = DLookup("[MilRate]", "tblMilRates", "[StartDate]=#" & _
DMax("[StartDate]", "tblMilRates", "[StartDate]<=#" & _
IIf(TravelDate = 0, Date, TravelDate) & "#") & "#")
Exit_GetMilRate:
Exit Function
Err_GetMilRate:
MsgBox "Function is GetMilRate" & vbNewLine & Err.Number & vbNewLine &
Err.Description
Resume Exit_GetMilRate
End Function
4. Every place in your queries that you have GetMilRate()
replace it with GetMilRate([TravelDate])
If you do have have [TravelDate] in all your queries,
you can leave it blank and it will use the current date.
Jack Cannon
TraciAnnNeedsHelp said:
Yes. Using the GetMilRate function in the query is calculating the mileage
correctly. The only problem is, I used Format("Fixed") to format the numbers
but for some reason it is left aligning the column, but that's minor.
I'm ready to have it apply the correct rate based on the date.