Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How make data print on report if form field is blank

Posted on 2013-12-19
3
Medium Priority
?
580 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 31

Expert Comment

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

Accepted Solution

by:
mbizup earned 2000 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 40

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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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 …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

783 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