• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 29
  • Last Modified:

Displaying on a report

I have this code in the onprint event of the detail section of a report which works fine if there is data:

    If Me.txtType2 = "COMPLETE" Then
        Me.chkbxConformed.Visible = True
        Me.txtRetDate.Visible = False
    End If

    If Not IsNull(Me.txtRetDate) Then
        If Me.txtType2 = "PLATING" Or Me.txtType2 = "CALIBRATION" Or Me.txtType2 = "CHECK FIT" Then
            Me.chkbxConformed.Visible = False
            Me.txtRetDate.Visible = True
        End If
    End If

Open in new window


But if the report has no data I get an error that reads, "You entered an expression that has no value.  The debug highlights the first line of the code.  How do I avoid this?
0
SteveL13
Asked:
SteveL13
1 Solution
 
SteveL13Author Commented:
Sorry...  correction in code:

    If Me.txtType2 = "COMPLETE" Then
        Me.chkbxConformed.Visible = True
        Me.txtRetDate.Visible = False
    End If

    If Me.txtType2 = "PLATING" Or Me.txtType2 = "CALIBRATION" Or Me.txtType2 = "CHECK FIT" Then
        Me.chkbxConformed.Visible = False
        Me.txtRetDate.Visible = True
    End If

Open in new window

0
 
Rey Obrero (Capricorn1)Commented:
try adding a  line to check if the report has data

if Reports("NameOfReport").HasData then

    If Me.txtType2 = "COMPLETE" Then
        Me.chkbxConformed.Visible = True
        Me.txtRetDate.Visible = False
    End If

    If Me.txtType2 = "PLATING" Or Me.txtType2 = "CALIBRATION" Or Me.txtType2 = "CHECK FIT" Then
        Me.chkbxConformed.Visible = False
        Me.txtRetDate.Visible = True
    End If
End if

or prior to opening the report, check if there will be data, cancel opening of the report is there is no data
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now