Private Sub cmdReport_Click()
Dim strWarning As String
'Warn if not last day of month
strWarning = "Would you like to view report to end of month?"
strMonthEndDate = DateSerial(Year(Me.txtAsOfDate), Month(Me.txtAsOfDate) + 1, 0)
'Warning
If Me.txtAsOfDate.Value <> strMonthEndDate Then
If MsgBox(strWarning, vbYesNo, "Not End of Month") = vbYes Then
Me.txtAsOfDate.Value = strMonthEndDate
End If
End If
'Change qryNewBusinessYTD
Dim strSQL As String
Dim qdf As QueryDef
Dim db As Database
'Set SQL
strSQL = "TRANSFORM Sum(qryPendingDetailByMonth.AbsoluteValue) AS SumOfAbsoluteValue "
strSQL = strSQL & "SELECT qryPendingDetailByMonth.AddReduce "
strSQL = strSQL & "FROM qryPendingDetailByMonth "
strSQL = strSQL & "WHERE (((qryPendingDetailByMonth.[Billing Effective Date])<= #" & Me.txtAsOfDate & "#)) "
strSQL = strSQL & "GROUP BY qryPendingDetailByMonth.AddReduce "
strSQL = strSQL & "PIVOT qryPendingDetailByMonth.[Change Type]"
Set db = CurrentDb
Set qdf = db.QueryDefs("qryNewBusinessYTD")
'Change WHERE Clause
qdf.sql = strSQL
Set qdf = Nothing
Set db = Nothing
'Open Report
DoCmd.OpenReport "rptRevenueTargets", acViewReport
'Reports
With Reports!rptRevenueTargets
'Label Month
.labelMonth.Caption = MonthName(Month(Me.txtAsOfDate), False) & " " & Year(Me.txtAsOfDate)
'--------------------------------
'MONTHLY ADDS AND REDUCTIONS
'--------------------------------
Dim strWhere As String
strWhere = "[Billing Effective Date] <= #" & Me.txtAsOfDate & "#"
strWhere = strWhere & "AND [Billing Effective Date] >= #" & DateSerial(Year(Me.txtAsOfDate), Month(Me.txtAsOfDate), 1) & "#"
'Set Focus to subreport
.srptMonthlyAddsReductions.SetFocus
With .srptMonthlyAddsReductions.Report
'Filter Report
.Filter = strWhere
.FilterOn = True
'Populate Label
Reports!rptRevenueTargets.srptMonthlyAddsReductions.Report.txtDateRange.Caption = MonthName(Month(Me.txtAsOfDate), False) & " " & Year(Me.txtAsOfDate) & " Summary"
End With
'--------------------------------
'NEW BUSINESS YTD
'--------------------------------
strWhere = "[Billing Effective Date] <= #" & Me.txtAsOfDate & "#"
With .srptCurrentYearNewBusiness.Report
'Title of Chart
.labelTitle.Caption = "New Business Run-Rate as of " & Me.txtAsOfDate
'Filter Report
.Filter = strWhere
.FilterOn = True
End With
'--------------------------------
'EMPLOYEE HEADCOUNT
'--------------------------------
'Need to update the query and report to be able to pick for a certain time period. Background work must be done _
' in Employee DB
'--------------------------------
'BUDGET - REVENUE & EXPENSES
'--------------------------------
'--------------------------------
'FUTURES CALENDAR
'--------------------------------
Dim strBeginDate As String
Dim strEndDate As String
Dim strYearEnd As String
Dim strSummaryBegin As String
Dim strSummaryRange As String
strBeginDate = "[Billing Effective Date] >= #" & Me.txtAsOfDate + 1 & "#"
strEndDate = "[Billing Effective Date] < #" & DateAdd("m", 3, Me.txtAsOfDate + 1) & "#"
strYearEnd = "[Billing Effective Date] <= #" & DateSerial(Year(Me.txtAsOfDate), 12, 31) & "#"
strWhere = strBeginDate & " AND " & strEndDate & " AND " & strYearEnd
strSummaryBegin = "[Billing Effective Date] >= #" & DateAdd("m", 3, Me.txtAsOfDate + 1) & "#"
strSummaryRange = strSummaryBegin & " AND " & strYearEnd
'Filter Futures Detail
With .srptFuturesCalendarDetail.Report
.Filter = strWhere
' .FilterOn = True
End With
'Filter Futures Summary
With .srptFuturesCalendarSummary.Report
.Filter = strSummaryRange
.FilterOn = True
End With
'--------------------------------
'BUYSIDE APPENDIX
'--------------------------------
strWhere = "[Category] = 'Buyside'"
strWhere = strWhere & " AND [Billing Effective Date] <= #" & Me.txtAsOfDate & "#"
'Filter Buyiside Appendix
With .srptBuysideAppendix.Report
.Filter = strWhere
.FilterOn = True
End With
'--------------------------------
'BUYSIDE CPU APPENDIX
'--------------------------------
strWhere = "[Billing Effective Date] <= #" & Me.txtAsOfDate & "#"
'Filter Buyside CPU Appendix
With .srptBuysideCPU.Report
.Filter = strWhere
'FAILS ON THE NEXT LINE (FilterOn=True)
.FilterOn = True
End With
'--------------------------------
'BROKER DEALER APPENDIX
'--------------------------------
'Filter BD Appendix
With .srptBDAppendix.Report
.Filter = strWhere & " AND [Category] = 'BD'"
.FilterOn = True
End With
'--------------------------------
'INDEX APPENDIX
'--------------------------------
Dim strIndex As String
strIndex = "left([Category],5) = 'Index' AND right([Category],10) <> 'Consulting'"
'Filter Index Appendix
With .srptIndexAppendix.Report
.Filter = strWhere & " AND " & strIndex
.FilterOn = True
End With
'--------------------------------
'BUSINESS PARTNERS APPENDIX
'--------------------------------
Dim strPartners As String
'Filter Business Partners Appendix
With .srptBusinessPartnersAppendix.Report
.Filter = strWhere & " AND [Category] = 'Business Partner'"
.FilterOn = True
End With
'--------------------------------
'BUSINESS CONSULTING
'--------------------------------
Dim strConsulting As String
strConsulting = "right([Category],10) = 'Consulting' OR left([Category],10) = 'Consulting'"
'Filter ConsultingIndex
With .srptConsultingAppendix.Report
.Filter = strWhere & " AND " & strConsulting
.FilterOn = True
End With
End With
'Print Preview
DoCmd.OpenReport "rptRevenueTargets", acViewPreview
'Zoom to Fit
DoCmd.RunCommand acCmdFitToWindow
'Close Filter
DoCmd.Close acForm, "frmRevenueTargetsFilter"
End Sub