Results 1 to 6 of 6

Thread: Access 2003 - Reports - Display message when no record exists

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Cool Access 2003 - Reports - Display message when no record exists

    Hi,
    I have a query in access which fetches Records based on a parameter supplied by the user at runtime. parameter "Enter Date:"
    Now I created a Report to display the above results.
    There could be occasions where there could be no records avaiable.
    During those occasion a message needs to be displayed "No Records available for this date."
    I was thinking of putting an invisible Label, in the pageHeader section, to do this job, which becomes visible only when there is no record fetched in the detail section. Some coding in this regard would be of much help.
    Thanks in advance

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Access 2003 - Reports - Display message when no record exists

    Was my post so complicated

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Access 2003 - Reports - Display message when no record exists

    The below code pops up a message box when no records are fetched...
    Code:
    Private Sub Report_NoData(Cancel As Integer)
        MsgBox "No records match the criteria you entered.", vbExclamation, "No Records Found"
        Cancel = True
    End Sub
    Now how about my original query of displaying a message in the report itself in the page header or some other location when no records are available..

  4. #4
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Access 2003 - Reports - Display message when no record exists

    One solution could be to call a new rpt inside that procedure (Report_NoData) and this new rpt only has the desired message of "No records match the criteria you entered" fixed in the report header section or where you like to

    JG

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Question Re: Access 2003 - Reports - Display message when no record exists

    Thanks jggtz
    But I believe there is a way to access individual elements/controls of a report I've seen something like that in CR (even that I've forgotten!!!)
    If we can get control of that then as suggested by you we can display a message in the header of the same report. Also note when there is no record the txt boxes in the details section display #Error may be this may come in handy

    I faintly remember how it was done in CR.
    You get the obj of the report, then access its individual sections->controls
    something like
    Code:
    report.GroupHeader(0).Text(0).Text="my message"

  6. #6
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,195

    Re: Access 2003 - Reports - Display message when no record exists

    Here is how you can change a reports text object.
    Code:
                Dim objT As CrystalDecisions.CrystalReports.Engine.TextObject
                objT = DirectCast(rpt.Section2.ReportObjects("txtReportType"), CrystalDecisions.CrystalReports.Engine.TextObject)
                objT.Text = "Amounts For " & strCYear
                If strRptType = "ALM" Then
                    objT = DirectCast(rpt.Section2.ReportObjects("txtHeader"), CrystalDecisions.CrystalReports.Engine.TextObject)
                    objT.Text = "Average Lift Minus(31-31/Used) Report"
                End If
    
                Me.CrystalReportViewer1.ReportSource = rpt
    also you will need this,
    Code:
    Imports CrystalDecisions.CrystalReports.Engine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width