473,890 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Report: How to hide field if empty?

1 New Member
In a report, I have fields for customer's address, Address 1, Address 2, Address 3. Very few people use all 3 fields. I am looking for some code to say..."if the field is null, don't print...ie. don't leave a blank line before you show me the city/state/zip. How can I do this?
Jan 20 '12 #1
11 14298
sierra7
446 Recognized Expert Contributor
Hi
The simplest way to do this (without using code) in a Report is to set the heights of the controls for Address2 and Address3 to zero but have their property 'Can Grow' set to Yes.

This is not perfect because there are still the accumulated spaces between the lines that will push city/state/zip down the page a little but this should not be bad and is an improvement on having a big gap.

S7
Jan 20 '12 #2
sierra7
446 Recognized Expert Contributor
Hi agian,
The alternative to my last post is to concatonate the three address lines thus.
Expand|Select|Wrap|Line Numbers
  1. =[Add1] & IIf(Not IsNull([Add2]),Chr(13) & Chr(10) & [Add2],"") & IIf(Not IsNull([Add3]),Chr(13) & Chr(10) & [Add3],"")
I had trouble making this work the other night because I had Chr(10) & Chr(13) the wrong way round, silly me!

These represent Carriage Return and Line Feed, so the next non null field is placed on the next line.

The control into which this is placed as the source code must have Can Grow set to Yes, so it can grow to the required height when three lines are present.

The name of the control cannot be the same as any of the fields it contains e.g. [Add1], [Add2] or [Add3], but calling it txtAdd1 is ok.
S7
Jan 22 '12 #3
NeoPa
32,584 Recognized Expert Moderator MVP
@S7.
There are two predefined values in VBA for Chr(13) & Chr(10) - vbCrLf and vbNewLine. Either will replace the two in your code (vbCr & vbLf are also available for each individually).

Furthermore, you may like to check out Using "&" and "+" in WHERE Clause for handling Null-resulting string expressions. Here's an illustration of what they can do :
Expand|Select|Wrap|Line Numbers
  1. =[Add1] & ([Add2] + vbCrLf) & ([Add3] + vbCrLf)
This will have the same result as your suggested code (which is perfectly correct of course), but a little shorter.
Jan 23 '12 #4
sierra7
446 Recognized Expert Contributor
@NeoPa
I did ofcourse try vbNewLine and vbCrLf before posting but they don't seem to work in the context of textbox controls. Access seems to interpret them as variables and wants a parameter input. (See pic)

The + instead of & is a neat shortcut though.

S7

Attached Images
File Type: jpg vbCrLf.jpg (7.3 KB, 6777 views)
Jan 23 '12 #5
NeoPa
32,584 Recognized Expert Moderator MVP
I'm sorry. I thought I'd checked that out (Essentially references from Jet SQL), but clearly I hadn't done so properly. That certainly makes more sense. I would have expected you to know about them, but I didn't want to say anything anyway. I'm still finding things, from time-to-time, that are new to me, but others have been using regularly. What's obvious to one is not always so to all others I find.
Jan 23 '12 #6
sierra7
446 Recognized Expert Contributor
@ NeoPa, ditto


(answers must be 20 characters!)
Jan 24 '12 #7
NeoPa
32,584 Recognized Expert Moderator MVP
Yup ;-)
Jan 24 '12 #8
ChrisPadgham
11 New Member
I think it would be better to put this logic in the query upon which the report is based rather than a text box.
Jan 24 '12 #9
NeoPa
32,584 Recognized Expert Moderator MVP
That would not make for a very nicely laid out report. In many cases it might make sense, but I doubt it would make much in this scenario.
Jan 24 '12 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5256
by: mstery | last post by:
I have a report generated via an ID selection made in a dropdown on a form. The report filters by an on click event in a preview report button on the form. Everything in the report, including subreports, filters perfectly, with the exception of a running sum DLookup field on the main report. This field looks up a value in a foreign table. I'm not clear where I'm supposed to be filtering this field, since it obviously isn't picking up the...
1
1731
by: Shapper | last post by:
Hello, I have this code line inside an ASP.Net Repeater: <a href='<%# DataBinder.Eval(Container.DataItem, "link") %>'><%= readMore %></a> What I need to do is: 1. Show readMore value if <%# DataBinder.Eval(Container.DataItem, "link") %> is not empty.
0
1078
by: Kalyan | last post by:
I already created report not with crystal report but through .net. Now I want to add new column in my database to crystal report. Field viewer is disabled. If i open crystal report in .net. My database is Access and i dont have access installed on my m/c. I am able to connect Database through ADO. Reports working fine. Thanks kalyan
0
1364
by: willemp | last post by:
i have a report with a 3 groups in it A - project B - person each record in the report consists of a single realised workday on a single project by a single person. so i have records that contain projectname,personname,date,worked hours, and the hours that where planned for this person on this project
3
2289
by: Dentharg | last post by:
Hi! I've created an C# project, added DataSet and created a table adaptor (WorkerClothesReport). I've created several GetData() functions and can preview their output. Next, I've created a Crystal report with WorkerClothes as data input. In my main window I've added report viewer and initialized it with
3
10509
by: smuir | last post by:
I am working with a basic access form for a payroll system and need to modify it such that if an employee worked overtime, then their overtime payrate and hours show up on the report below their regular payrate and hours. Ex: 40.00 hours @ $77.00/hr 5.00 hours @ $102.00/hr If an employee's overtime hours = 0, then the overtime payrate and hours fields should not be visible on the report. Ex: 40.00 hours @ $77.00/hr
2
4319
Cintury
by: Cintury | last post by:
Hello, I saw a similar thread on this subject but did not find the answer I was looking for. I have a report that is used to find undistributed balances of food using a table and a subreport. It includes Date/Donor Company/Bakery/Dairy/Meat/Fruit/Veg/Prod/Prep'd/Bev/Non-Perish/Non-Food/Total Under that if the "Cross-reference" button is selected it shows the Agency it was delivered to. (Same run through as above "Receiving Agency" instead...
8
12954
by: elastreto | last post by:
Hello, I have been trying, so far in vain, to hide the label and text control in a form when the text control is empty/null. I have looked at past postings and tried the code below, however I am getting Run-Time Error 438, stating that the object doesn’t support this property or method. I don't know if I am writing the code to the wrong place or if I have an error in the code itself. Any help is appreciated!! (I am running Access...
5
4026
by: DAHMB | last post by:
Hi all, Using Access 2007 I have a report called Sunday School Attendance based on a Query called qryAttendance the query is as follows: SELECT tblSundaySchoolAttendance.StudentID, tblSundaySchoolAttendance.AttendanceDate, . FROM tblSundaySchoolAttendance INNER JOIN ON tblSundaySchoolAttendance.StudentID=.StudentID;
2
2424
by: puT3 | last post by:
How can I make the report do not show any empty records? For example, in this table do not has address...I want the report only shows company that has address
0
9980
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11236
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10830
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9641
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5855
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4276
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.