M
Mishanya
I've built a form wich serves as "limiter-opener" for MyReport using:
1) A. Browne's Popup Calendar utility (form and modul) to select StartDate
and EndDate
2) A. Browne code from http://allenbrowne.com/casu-08.html to open MyReport
filtered for the selected dates.
The code works fine while opening MyReport directly:
Private Sub btnOpenMyReport_Click()
Dim strReport As String
Dim strDateField As String
Dim strWhere As String
Dim lngView As Long
Const strcJetDate = "\#mm\/dd\/yyyy\#"
strReport = "MyReport"
strDateField = "[Date]"
lngView = acViewPreview
If IsDate(Me.StartDate) Then
strWhere = "(" & strDateField & " >= " & Format(Me.StartDate,
strcJetDate) & ")"
End If
If IsDate(Me.EndDate) Then
If strWhere <> vbNullString Then
strWhere = strWhere & " AND "
End If
strWhere = strWhere & "(" & strDateField & " < " & Format(Me.EndDate + 1,
strcJetDate) & ")"
End If
DoCmd.OpenReport strReport, lngView, , strWhere
End Sub
Now I need to tune this, because MyReport is actually subreport of
MainReport (as a part of the MainReport it should present transactions
limited to the date-range).
I've changed the following part:
strReport = "MainReport"
strDateField = "Reports![MainReport]![MyReport].Report![Date]"
but the result is blank MainReport.
Is it possible to filter the date-range of subreport by coding in such a
manner a control-button used for opening the MainReport?
If it is, please correct my code. Also please, show me how to add to the
code additional filter for ClientID (the form wich limits and opens the
MainReport has ClientID control).
Thanks in advance.
1) A. Browne's Popup Calendar utility (form and modul) to select StartDate
and EndDate
2) A. Browne code from http://allenbrowne.com/casu-08.html to open MyReport
filtered for the selected dates.
The code works fine while opening MyReport directly:
Private Sub btnOpenMyReport_Click()
Dim strReport As String
Dim strDateField As String
Dim strWhere As String
Dim lngView As Long
Const strcJetDate = "\#mm\/dd\/yyyy\#"
strReport = "MyReport"
strDateField = "[Date]"
lngView = acViewPreview
If IsDate(Me.StartDate) Then
strWhere = "(" & strDateField & " >= " & Format(Me.StartDate,
strcJetDate) & ")"
End If
If IsDate(Me.EndDate) Then
If strWhere <> vbNullString Then
strWhere = strWhere & " AND "
End If
strWhere = strWhere & "(" & strDateField & " < " & Format(Me.EndDate + 1,
strcJetDate) & ")"
End If
DoCmd.OpenReport strReport, lngView, , strWhere
End Sub
Now I need to tune this, because MyReport is actually subreport of
MainReport (as a part of the MainReport it should present transactions
limited to the date-range).
I've changed the following part:
strReport = "MainReport"
strDateField = "Reports![MainReport]![MyReport].Report![Date]"
but the result is blank MainReport.
Is it possible to filter the date-range of subreport by coding in such a
manner a control-button used for opening the MainReport?
If it is, please correct my code. Also please, show me how to add to the
code additional filter for ClientID (the form wich limits and opens the
MainReport has ClientID control).
Thanks in advance.