Solved

How make data print on report if form field is blank

Posted on 2013-12-19
3
565 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 37

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

751 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