Solved

How make data print on report if form field is blank

Posted on 2013-12-19
3
559 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 35

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

770 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