[AccessD] Problem with A2003 Report caption

A.D.TEJPAL adtp at airtelbroadband.in
Mon Aug 6 13:55:22 CDT 2007


Bob,

    You can try passing the caption string as report's OpenArgs as follows:

    DoCmd.OpenReport strReportName, _
            acViewPreview, , strWhere, , strReportCaption

    Code in report's open event would be:

    Private Sub Report_Open(Cancel As Integer)
        Me.Caption = Me.OpenArgs
    End Sub

Best wishes,
A.D.Tejpal
---------------

  ----- Original Message ----- 
  From: Bob Gajewski 
  To: 'Access Developers discussion and problem solving' 
  Sent: Monday, August 06, 2007 11:06
  Subject: [AccessD] Problem with A2003 Report caption


  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


More information about the AccessD mailing list