R
rpw
hi everyone
sorry for the length of this post, but before i state the problem, i'd like to provide enought support info. here's the layout of the db - i've got 3 tables
tblMileageExpens
MileageExpenseID (PK
MileageTypeID (FK
RateI
StartMile
EndMile
MileageDat
tblMileageRat
RateID (PK
MileageTypeID (FK
Rat
EffDate ' effective dat
tblMileageTyp
MileageTypeID (PK
TypeDes
i want a report that will list the tblMileageExpense records and calculate mileage expenses by using the most recent Rate that is not more recent than the mileage date (where the MAX(EffDate) is <= the MileageDate
here's the SQL that gets me halfway there
SELECT tblMileageExpense.MileageExpenseID, tblMileageExpense.MileageDate, tblMileageExpense.StartMiles, tblMileageExpense.EndMiles, tblMileageExpense.MileageTypeID, tblMileageType.TypeDesc, tblMileageRate.Rate, tblMileageRate.EffDate, tblMileageExpense.RateI
FROM (tblMileageType INNER JOIN tblMileageExpense ON tblMileageType.MileageTypeID = tblMileageExpense.MileageTypeID) INNER JOIN tblMileageRate ON tblMileageType.MileageTypeID = tblMileageRate.MileageTypeI
WHERE (((tblMileageExpense.MileageDate)>=[tblMileageRate]![EffDate]))
this would list the same MileageExpense record for every occurance of the WHERE claus
when i've tried to use MAX in the above report query, it results in "cannot combine aggregate functions" error
if i try to put similar (using dlookup or dmax) into the control source for RateID on the Expense form, i get circular reference errors
i'm thinking that the solution is VBA code that loops through comparing MileageDate to EffDate until EffDate is no longer less than Mileage date (but i don't know how to do this
any and all help is appreciate
TI
rp
btw, i don't want to have a combo on the form for the user to select which rate to use - i want it automated to select the rate that applies to the time frame of the mileage dat
sorry for the length of this post, but before i state the problem, i'd like to provide enought support info. here's the layout of the db - i've got 3 tables
tblMileageExpens
MileageExpenseID (PK
MileageTypeID (FK
RateI
StartMile
EndMile
MileageDat
tblMileageRat
RateID (PK
MileageTypeID (FK
Rat
EffDate ' effective dat
tblMileageTyp
MileageTypeID (PK
TypeDes
i want a report that will list the tblMileageExpense records and calculate mileage expenses by using the most recent Rate that is not more recent than the mileage date (where the MAX(EffDate) is <= the MileageDate
here's the SQL that gets me halfway there
SELECT tblMileageExpense.MileageExpenseID, tblMileageExpense.MileageDate, tblMileageExpense.StartMiles, tblMileageExpense.EndMiles, tblMileageExpense.MileageTypeID, tblMileageType.TypeDesc, tblMileageRate.Rate, tblMileageRate.EffDate, tblMileageExpense.RateI
FROM (tblMileageType INNER JOIN tblMileageExpense ON tblMileageType.MileageTypeID = tblMileageExpense.MileageTypeID) INNER JOIN tblMileageRate ON tblMileageType.MileageTypeID = tblMileageRate.MileageTypeI
WHERE (((tblMileageExpense.MileageDate)>=[tblMileageRate]![EffDate]))
this would list the same MileageExpense record for every occurance of the WHERE claus
when i've tried to use MAX in the above report query, it results in "cannot combine aggregate functions" error
if i try to put similar (using dlookup or dmax) into the control source for RateID on the Expense form, i get circular reference errors
i'm thinking that the solution is VBA code that loops through comparing MileageDate to EffDate until EffDate is no longer less than Mileage date (but i don't know how to do this
any and all help is appreciate
TI
rp
btw, i don't want to have a combo on the form for the user to select which rate to use - i want it automated to select the rate that applies to the time frame of the mileage dat