Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / December 2005

Tip: Looking for answers? Try searching our database.

Crosstab aging report

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Newbie - 02 Dec 2005 12:49 GMT
Office 2003

I want to create a report similar to an aged debt report.  I want the
columns to be
0-14 days
15-30 days
31-60 days
61-90 days
90 days and over

I have the following (amended from a post I found by Duane) but am not sure
how to do the pivot section.
The DateDiff("d",[tDate],forms!frmDate.dtpFrom)/30)*30)) line that was part
of the original post didn't work as it didn't show the amounts in any column
when the result of the days was not in the Mth0 or Mth90 column

What do I need to do?
Thanks

PARAMETERS Forms!frmDate.dtpFrom DateTime;
TRANSFORM Sum(Debtors.AmountOS) AS TotalOS
SELECT Debtors.Acc, Debtors.AccName, Debtors.InvNo, Debtors.Note
FROM Debtors
GROUP BY Debtors.Acc, Debtors.AccName, Debtors.InvNo, Debtors.Note
PIVOT "Mth" &
IIf(DateDiff("d",[tDate],forms!frmDate.dtpFrom)>90,"90",iif(DateDiff("d",[tDate],forms!frmDate.dtpFrom)<15,
"14",
(DateDiff("d",[tDate],forms!frmDate.dtpFrom)/30)*30)) In ("Mth14","Mth30",
"Mth60","Mth90");
Duane Hookom - 02 Dec 2005 15:22 GMT
I would either create a public function in a module of business calculations
or a table of day ranges. I generally consider nesting more than 2 IIf()s a
mistake. The following is the function method. You can search google groups
for a table of ranges.

Public Function GetAging(datStart As Date, datEnd As Date) As String
   Dim intDays As Integer
   intDays = DateDiff("d", datStart, datEnd)
   Select Case intDays
       Case Is <= 14
           GetAging = "0-14 Days"
       Case Is <= 30
           GetAging = "15-30 Days"
       Case Is <= 60
           GetAging = "31-60 Days"
       Case Is <= 90
           GetAging = "61-90 Days"
       Case Else
           GetAging = "90 Days and Over"
   End Select
End Function

PARAMETERS Forms!frmDate.dtpFrom DateTime;
TRANSFORM Sum(Debtors.AmountOS) AS TotalOS
SELECT Debtors.Acc, Debtors.AccName, Debtors.InvNo, Debtors.Note
FROM Debtors
GROUP BY Debtors.Acc, Debtors.AccName, Debtors.InvNo, Debtors.Note
PIVOT GetAging([tDate],forms!frmDate.dtpFrom) In ("0-14 Days","15-30
Days",..etc..);
Signature

Duane Hookom
MS Access MVP
--

> Office 2003
>
[quoted text clipped - 25 lines]
> (DateDiff("d",[tDate],forms!frmDate.dtpFrom)/30)*30)) In ("Mth14","Mth30",
> "Mth60","Mth90");
Newbie - 02 Dec 2005 15:51 GMT
Brilliant - I had got it to work using the nested iifs  but this function
looks so much more friendly

Thanks
A
>I would either create a public function in a module of business
>calculations or a table of day ranges. I generally consider nesting more
[quoted text clipped - 55 lines]
>> (DateDiff("d",[tDate],forms!frmDate.dtpFrom)/30)*30)) In
>> ("Mth14","Mth30", "Mth60","Mth90");
Duane Hookom - 02 Dec 2005 15:58 GMT
WHEN your day ranges change, it is much easier to modify the function rather
than a horribly long nested IIf().

Signature

Duane Hookom
MS Access MVP
--

> Brilliant - I had got it to work using the nested iifs  but this function
> looks so much more friendly
[quoted text clipped - 60 lines]
>>> (DateDiff("d",[tDate],forms!frmDate.dtpFrom)/30)*30)) In
>>> ("Mth14","Mth30", "Mth60","Mth90");
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.