Solved

How make data print on report if form field is blank

Posted on 2013-12-19
3
557 Views
Last Modified: 2013-12-20
I have a field on a report and the control source is:

=[Forms]![frmSelectDateRangeSourceOfSalesRpt]![txtMemberName]

But if the field on the form is blank I want the field to print "All Members"

Here is the on print code I have but it doesn't work.

    If Me.txtTeamMember = "" Then
        Me.txtTeamMember = "All Members"
    End If
0
Comment
Question by:SteveL13
3 Comments
 
LVL 30

Expert Comment

by:hnasr
ID: 39730408
Try On Format event.
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39730415
You don't need the VBA.

Just set the control source as follows:


=iif ( Trim("" & [Forms]![frmSelectDateRangeSourceOfSalesRpt]![txtMemberName]) = "", "ALL MEMBERS",  [Forms]![frmSelectDateRangeSourceOfSalesRpt]![txtMemberName])

Open in new window

0
 
LVL 34

Expert Comment

by:PatHartman
ID: 39730861
"" is a ZLS (zero length string) and is different from Null.  The following code simplifies the test for both values.  It concatenates a ZLS with the field and then tests to see if it is still equal to a ZLS.  This takes advantage of the concatenation properties of & when dealing with a null value because when you concatenate a ZLS with Null, you end up with a ZLS.

    If Me.txtTeamMember & "" = "" Then
        Me.txtTeamMember = "All Members"
    End If 

Open in new window

0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

863 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

28 Experts available now in Live!

Get 1:1 Help Now