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?
11 14225
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
Hi agian,
The alternative to my last post is to concatonate the three address lines thus. - =[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
NeoPa 32,556
Expert Mod 16PB
@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 : - =[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.
@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 NeoPa 32,556
Expert Mod 16PB
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.
@ NeoPa, ditto
(answers must be 20 characters!)
NeoPa 32,556
Expert Mod 16PB
I think it would be better to put this logic in the query upon which the report is based rather than a text box.
NeoPa 32,556
Expert Mod 16PB
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.
I fail to see how it would have any effect on the layout of the report, the text box on the report would reference the calculated field in the query. You are simply moving the calculations from the form to the query upon which it is based.
NeoPa 32,556
Expert Mod 16PB
You're absolutely right Chris.
Put it down to a brain-fart. It's late and I'm tired. I was (mis) remembering that the report was working with multiple controls, but clearly it wasn't.
PS. Like you, I'd generally do it that way. In this case though, help for handling the ControlSource of a control in their existing report was requested (and provided). Your point is well worth making though, nevertheless.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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 <%#...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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,...
|
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...
|
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,...
|
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...
| |