J
JK
Would anyone be able to tell me why I cannot run the following query based on
a date range? I want the user to be able to enter a date range into a form
and then have the form pull the report based that date range. For some
reason, it's not working. I'm using access 2003; if you need more
information, please let me know.
Thanks!
Jason
SELECT qryDepreciationCartesian_RPT.DepreciationID,
qryDepreciationCartesian_RPT.InstanceID,
IIf(DepreciationException.DepreciationID Is
Null,IIf((qryDepreciationCartesian_RPT.PeriodTypeID Is Null) Or
(qryDepreciationCartesian_RPT.PeriodFreq Is Null) Or
(qryDepreciationCartesian_RPT.InstanceID Is
Null),qryDepreciationCartesian_RPT.PurchaseDate,DateAdd(qryDepreciationCartesian_RPT.PeriodTypeID,qryDepreciationCartesian_RPT.InstanceID*qryDepreciationCartesian_RPT.PeriodFreq,qryDepreciationCartesian_RPT.PurchaseDate)),IIf(DepreciationException.IsCanned,Null,DepreciationException.InstanceDate))
AS DepDate, qryDepreciationCartesian_RPT.PurchaseDate,
qryDepreciationCartesian_RPT.DepreciableLife, DepreciationException.IsCanned,
qryDepreciationCartesian_RPT.AssetID,
qryDepreciationCartesian_RPT.PurchasePrice,
qryDepreciationCartesian_RPT.SalvageValue,
qryDepreciationCartesian_RPT.DepreciationDate,
qryDepreciationCartesian_RPT.DepreciationAmount,
qryDepreciationCartesian_RPT.PeriodFreq, DepPeriodType.PeriodType,
DDB([PurchasePrice],[SalvageValue],[DepreciableLife],[InstanceID]) AS myDDB,
qryDepreciationCartesian_RPT.Comment, DepreciationException.InstanceComment,
qryDepreciationAssets.AssetName, qryDepreciationAssets.AssetDescription,
qryDepreciationAssets.Category, qryDepreciationAssets.DateSold
FROM ((qryDepreciationCartesian_RPT LEFT JOIN DepreciationException ON
(qryDepreciationCartesian_RPT.DepreciationID =
DepreciationException.DepreciationID) AND
(qryDepreciationCartesian_RPT.InstanceID = DepreciationException.InstanceID))
LEFT JOIN DepPeriodType ON qryDepreciationCartesian_RPT.PeriodTypeID =
DepPeriodType.PeriodTypeId) INNER JOIN qryDepreciationAssets ON
qryDepreciationCartesian_RPT.AssetID = qryDepreciationAssets.ID
WHERE ((Not (qryDepreciationCartesian_RPT.DepreciationID) Is Null) AND
((IIf([DepreciationException].[DepreciationID] Is
Null,IIf(([qryDepreciationCartesian_RPT].[PeriodTypeID] Is Null) Or
([qryDepreciationCartesian_RPT].[PeriodFreq] Is Null) Or
([qryDepreciationCartesian_RPT].[InstanceID] Is
Null),[qryDepreciationCartesian_RPT].[PurchaseDate],DateAdd([qryDepreciationCartesian_RPT].[PeriodTypeID],[qryDepreciationCartesian_RPT].[InstanceID]*[qryDepreciationCartesian_RPT].[PeriodFreq],[qryDepreciationCartesian_RPT].[PurchaseDate])),IIf([DepreciationException].[IsCanned],Null,[DepreciationException].[InstanceDate])))
Between [Forms]![frmReport_EventsByAsset]![txtBeginning] And
[Forms]![frmReport_EventsByAsset]![txtEnding]))
ORDER BY qryDepreciationCartesian_RPT.DepreciationID,
qryDepreciationCartesian_RPT.InstanceID;
a date range? I want the user to be able to enter a date range into a form
and then have the form pull the report based that date range. For some
reason, it's not working. I'm using access 2003; if you need more
information, please let me know.
Thanks!
Jason
SELECT qryDepreciationCartesian_RPT.DepreciationID,
qryDepreciationCartesian_RPT.InstanceID,
IIf(DepreciationException.DepreciationID Is
Null,IIf((qryDepreciationCartesian_RPT.PeriodTypeID Is Null) Or
(qryDepreciationCartesian_RPT.PeriodFreq Is Null) Or
(qryDepreciationCartesian_RPT.InstanceID Is
Null),qryDepreciationCartesian_RPT.PurchaseDate,DateAdd(qryDepreciationCartesian_RPT.PeriodTypeID,qryDepreciationCartesian_RPT.InstanceID*qryDepreciationCartesian_RPT.PeriodFreq,qryDepreciationCartesian_RPT.PurchaseDate)),IIf(DepreciationException.IsCanned,Null,DepreciationException.InstanceDate))
AS DepDate, qryDepreciationCartesian_RPT.PurchaseDate,
qryDepreciationCartesian_RPT.DepreciableLife, DepreciationException.IsCanned,
qryDepreciationCartesian_RPT.AssetID,
qryDepreciationCartesian_RPT.PurchasePrice,
qryDepreciationCartesian_RPT.SalvageValue,
qryDepreciationCartesian_RPT.DepreciationDate,
qryDepreciationCartesian_RPT.DepreciationAmount,
qryDepreciationCartesian_RPT.PeriodFreq, DepPeriodType.PeriodType,
DDB([PurchasePrice],[SalvageValue],[DepreciableLife],[InstanceID]) AS myDDB,
qryDepreciationCartesian_RPT.Comment, DepreciationException.InstanceComment,
qryDepreciationAssets.AssetName, qryDepreciationAssets.AssetDescription,
qryDepreciationAssets.Category, qryDepreciationAssets.DateSold
FROM ((qryDepreciationCartesian_RPT LEFT JOIN DepreciationException ON
(qryDepreciationCartesian_RPT.DepreciationID =
DepreciationException.DepreciationID) AND
(qryDepreciationCartesian_RPT.InstanceID = DepreciationException.InstanceID))
LEFT JOIN DepPeriodType ON qryDepreciationCartesian_RPT.PeriodTypeID =
DepPeriodType.PeriodTypeId) INNER JOIN qryDepreciationAssets ON
qryDepreciationCartesian_RPT.AssetID = qryDepreciationAssets.ID
WHERE ((Not (qryDepreciationCartesian_RPT.DepreciationID) Is Null) AND
((IIf([DepreciationException].[DepreciationID] Is
Null,IIf(([qryDepreciationCartesian_RPT].[PeriodTypeID] Is Null) Or
([qryDepreciationCartesian_RPT].[PeriodFreq] Is Null) Or
([qryDepreciationCartesian_RPT].[InstanceID] Is
Null),[qryDepreciationCartesian_RPT].[PurchaseDate],DateAdd([qryDepreciationCartesian_RPT].[PeriodTypeID],[qryDepreciationCartesian_RPT].[InstanceID]*[qryDepreciationCartesian_RPT].[PeriodFreq],[qryDepreciationCartesian_RPT].[PurchaseDate])),IIf([DepreciationException].[IsCanned],Null,[DepreciationException].[InstanceDate])))
Between [Forms]![frmReport_EventsByAsset]![txtBeginning] And
[Forms]![frmReport_EventsByAsset]![txtEnding]))
ORDER BY qryDepreciationCartesian_RPT.DepreciationID,
qryDepreciationCartesian_RPT.InstanceID;