[AccessD] Problem with A2003 Report caption

Bob Gajewski rbgajewski at roadrunner.com
Mon Aug 6 00:36:45 CDT 2007


Hi Folks

I am running into a problem with a new report. I am using a form to select
record types and a date range, and passing the parameters to the report.
Everything is working perfectly and as expected *EXCEPT* that my report
caption does not print on the first page. It's there from Page 2 through the
end, regardless of how many pages.

My form code sample is below. I have confirmed that the value of
"frmDateRange" just prior to the OpenReport is "1". On the actual report,
the unbound text field for the report title has a control source of
"=[Caption]". 

If anyone has any ideas on how to fix this, or can at least point me in the
right direction, I will be truly grateful. 

Thanks !
Bob Gajewski


CODE SAMPLE (frmMembersResponses)
=================================
Private Sub cmdGenerateReport_Click()
On Error GoTo Err_cmdGenerateReport_Click

Dim strReportName As String, strWhere As String

    strReportName = "rptMembersResponse"
    strWhere = ""

' Set strWhere for Date Range
    If Not IsNull(Me!dteDateRangeSelectFrom) Or Me!dteDateRangeSelectFrom <>
"" Then
        If IsNull(strWhere) Or strWhere = "" Then
            strWhere = "([IncidentDate] >= #" & Me!dteDateRangeSelectFrom &
"#)"
        Else
            strWhere = "(" & strWhere & ") And ([IncidentDate] >= #" &
Me!dteDateRangeSelectFrom & "#)"
        End If
    End If
    If Not IsNull(Me!dteDateRangeSelectTo) Or Me!dteDateRangeSelectTo <> ""
Then
        If IsNull(strWhere) Or strWhere = "" Then
            strWhere = "([IncidentDate] <= #" & Me!dteDateRangeSelectTo &
"#)"
        Else
            strWhere = "(" & strWhere & ") And ([IncidentDate] <= #" &
Me!dteDateRangeSelectTo & "#)"
        End If
    End If

' Print report
    Dim rpt As Report, strReportCaption As String
        If IsNull(strWhere) Or strWhere = "" Then
            Select Case frmDateRange
                Case 1
                    strReportCaption = "Member Responses for Call Year " &
Format([dteDateRangeSelectFrom], "MM/DD/YYYY") & " - " &
Format([dteDateRangeSelectTo], "MM/DD/YYYY")
                Case 2
                    strReportCaption = "Member Responses for Calendar Year "
& DatePart("yyyy", [dteDateRangeSelectFrom])
                Case 3
                    strReportCaption = "Member Responses for " &
Format([dteDateRangeSelectFrom], "MM/DD/YYYY") & " - " &
Format([dteDateRangeSelectTo], "MM/DD/YYYY")
                Case Else
                    strReportCaption = "Member Responses"
            End Select
        Else
            Select Case frmDateRange
                Case 1
                    strReportCaption = "Selected Member Responses for Call
Year " & Format([dteDateRangeSelectFrom], "MM/DD/YYYY") & " - " &
Format([dteDateRangeSelectTo], "MM/DD/YYYY")
                Case 2
                    strReportCaption = "Selected Member Responses for
Calendar Year " & DatePart("yyyy", [dteDateRangeSelectFrom])
                Case 3
                    strReportCaption = "Selected Member Responses for " &
Format([dteDateRangeSelectFrom], "MM/DD/YYYY") & " - " &
Format([dteDateRangeSelectTo], "MM/DD/YYYY")
                Case Else
                    strReportCaption = "Selected Member Responses"
            End Select
        End If
    MsgBox ("The value of 'strReportCaption' is " & strReportCaption & ".")
    DoCmd.OpenReport strReportName, acViewPreview, , strWhere
    Set rpt = Reports(strReportName)
        rpt.OrderByOn = True
        rpt.OrderBy = strSortOrder
        rpt.Caption = strReportCaption

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.4/936 - Release Date: 08/04/2007
14:42 PM
 




More information about the AccessD mailing list