Solved

Displaying on a report

Posted on 2016-10-27
2
15 Views
Last Modified: 2016-10-27
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
Comment
Question by:SteveL13
2 Comments
 

Author Comment

by:SteveL13
Comment Utility
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
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now