As the dates are in separate columns in the table to group them by month
you'll need to get the year and month for each into the same columns in the
query on which the report is based so you can group by them. You can do this
with a union query, e.g.
SELECT [Contract], [Contract Signed], [Cancelled], [Contact Amount],
YEAR([Contact Signed]) AS TransactionYear,
MONTH([Contact Signed]) AS TransactionMonth
WHERE [Cancelled] IS NULL
UNION ALL
SELECT [Contract], [Contract Signed], [Cancelled], [Contact Amount],
YEAR([Cancelled]), MONTH([Cancelled])
WHERE [Cancelled] IS NOT NULL;
Group the report on TransactionYear and TransactionMonth columns and give
the latter group a group footer.
In the group footer add two text boxes for the two totals. If by
'totalling' you mean counting the instances of contracts signed and cancelled
per month then for signed contracts you'd use an expression like this for the
ControlSource of the text box:
=Sum(IIf(IsNull([Cancelled]) Or Format([Cancelled],"yyyymm") =
Format([Contract Signed],"yyyymm"), 1, 0))
and for the cancelled contracts:
=Sum(IIf(Not IsNull([Cancelled]), 1, 0))
If by totalling you mean summing some other column, e.g. Contact Amount,
then substitute the name of the column for the 1 constants in the above
expressions.
To open the report for a month or range of months create a dialogue form
with text boxes YearStart, MonthStart and YearEnd and Month end in which the
parameters can be entered as numbers. Add a button to the form with code to
open the report like this:
Const conREPORT = "YourReportNameGoesHere"
Dim strCtriteria As String
Dim dtmStart as Date, dtmEnd As Date
dtmStart = DateSerial(Me.YearStart, Me.MonthStart, 1)
dtmEnd = DateSerial(Me.YearEnd, Me.MonthEnd + 1, 0)
strCriteria = _
"[Contract Date] Between #" & _
"Format(dtmStart,"mm/dd/yyyy") & "# And " & _
"Format(dtmEnd,"mm/dd/yyyy") & "# Or " & _
"[Cancelled] Between #" & _
"Format(dtmStart,"mm/dd/yyyy") & "# And " & _
"Format(dtmEnd,"mm/dd/yyyy") & "#"
DoCmd.OpenReporst conREPORT, _
View:=acViewPreview, _
WhereCondition:=strCriteria
Ken Sheridan
Stafford, England
JenISCM said:
I have a report where I need to report data for the same record in two ways.
I can have a Contract Signed date and a Cancelled date for the same record.
I need to create a report to compare this data monthly – totaling all the
Contract Signed in that month and all the Cancelled items in that month.
(These date can occur in the same OR separate months.)
I also need to be able to run this report for specified time periods. (Ex:
Jan – Jun, or just the month of Dec, etc.)
Any assistance would be GREATLY appreciated.