473,394 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Conditional Concatenation in Reports

Hi,

I have an annoying little problem in that I am trying to report on a list od
Departments, Dept Heads and Deputies so I have the following in my report:

=DepartmentName & IIf(IsEmpty([DeptHeadName]),""," (" & [DeptHeadName] &
IIf(Isempty([DeptDeputyName]),")"," / " & [DetDeputyName] & ")"))

So what I exect to get is say

Marketting (Barney Rubble)
or
Purchasing (Fred Flintstone / Britney Spears)

what I am getting is

Marketting (Barney Rubble / )

oe in a department where no head and deputy have been assigned yet I get

Adminiatration ( / )
rather than just
Administration

I have tried IsNull instead of IsEmpty
I have tried DeptHeadName = ""
and
DeptHeadName = " "

It all seems so simple in the help and on the examples I have found on the
web... where am I going wrong...?

Any help appreciated as always

Ian
Nov 12 '05 #1
7 1608
How about

departmentname & iif(isnull(deptheadname) and
isnull(deptdeputyname),"","(") & deptheadname +
iif(isnull(deptdeputyname),"","/") & deptdeputyname &
iif(isnull(deptheadname) and isnull(deptdeputyname),"",")")

the + trick will show both ends if they are not null (and the / is never
null of course) and if there would always be a deptheadname, the whole
expression would be a lot simpler. But I read it isn't that simple.

It takes some evaluation. Maybe you can put some of the calculations in
the datasource?

Keldar wrote:
Hi,

I have an annoying little problem in that I am trying to report on a list od
Departments, Dept Heads and Deputies so I have the following in my report:

=DepartmentName & IIf(IsEmpty([DeptHeadName]),""," (" & [DeptHeadName] &
IIf(Isempty([DeptDeputyName]),")"," / " & [DetDeputyName] & ")"))

So what I exect to get is say

Marketting (Barney Rubble)
or
Purchasing (Fred Flintstone / Britney Spears)

what I am getting is

Marketting (Barney Rubble / )

oe in a department where no head and deputy have been assigned yet I get

Adminiatration ( / )
rather than just
Administration

I have tried IsNull instead of IsEmpty
I have tried DeptHeadName = ""
and
DeptHeadName = " "

It all seems so simple in the help and on the examples I have found on the
web... where am I going wrong...?

Any help appreciated as always

Ian


--
Bas Cost Budde

Nov 12 '05 #2
There's a really cool solution to this. Use the ampersand (&) mixed with
the plus sign (+) to filter nulls.

Result = [DeptHeadName] & (" / " + [DetDeputyName])

If DetDeputyName is null, plussing it with a string text results in NULL.
--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com/datafast
"Keldar" <ia*******@keldar.freeserve.co.uk> wrote ...
Hi,

I have an annoying little problem in that I am trying to report on a list od
Departments, Dept Heads and Deputies so I have the following in my report:

=DepartmentName & IIf(IsEmpty([DeptHeadName]),""," (" & [DeptHeadName] &
IIf(Isempty([DeptDeputyName]),")"," / " & [DetDeputyName] & ")"))

So what I exect to get is say

Marketting (Barney Rubble)
or
Purchasing (Fred Flintstone / Britney Spears)

what I am getting is

Marketting (Barney Rubble / )

oe in a department where no head and deputy have been assigned yet I get

Adminiatration ( / )
rather than just
Administration

I have tried IsNull instead of IsEmpty
I have tried DeptHeadName = ""
and
DeptHeadName = " "

It all seems so simple in the help and on the examples I have found on the
web... where am I going wrong...?

Nov 12 '05 #3
I think I get your Jist...

I am back in the office tomorrow and will try it out

Thanks

"Bas Cost Budde" <ba*@heuveltop.org> wrote in message
news:bv**********@news2.solcon.nl...
How about

departmentname & iif(isnull(deptheadname) and
isnull(deptdeputyname),"","(") & deptheadname +
iif(isnull(deptdeputyname),"","/") & deptdeputyname &
iif(isnull(deptheadname) and isnull(deptdeputyname),"",")")

the + trick will show both ends if they are not null (and the / is never
null of course) and if there would always be a deptheadname, the whole
expression would be a lot simpler. But I read it isn't that simple.

It takes some evaluation. Maybe you can put some of the calculations in
the datasource?

Keldar wrote:
Hi,

I have an annoying little problem in that I am trying to report on a list od Departments, Dept Heads and Deputies so I have the following in my report:
=DepartmentName & IIf(IsEmpty([DeptHeadName]),""," (" & [DeptHeadName] &
IIf(Isempty([DeptDeputyName]),")"," / " & [DetDeputyName] & ")"))

So what I exect to get is say

Marketting (Barney Rubble)
or
Purchasing (Fred Flintstone / Britney Spears)

what I am getting is

Marketting (Barney Rubble / )

oe in a department where no head and deputy have been assigned yet I get

Adminiatration ( / )
rather than just
Administration

I have tried IsNull instead of IsEmpty
I have tried DeptHeadName = ""
and
DeptHeadName = " "

It all seems so simple in the help and on the examples I have found on the web... where am I going wrong...?

Any help appreciated as always

Ian


--
Bas Cost Budde

Nov 12 '05 #4
Welcome.
Not a native english speaker, I'd like to understand the 'feel' conveyed
by Jist. Would you like to tell me the short story?

Keldar wrote:
I think I get your Jist...


--
Bas Cost Budde

Nov 12 '05 #5
My first thought too; it seems however that deptheadname can be null as
well, in which case he's left with that '/'

Danny J. Lesandrini wrote:
There's a really cool solution to this. Use the ampersand (&) mixed with
the plus sign (+) to filter nulls.

Result = [DeptHeadName] & (" / " + [DetDeputyName])

If DetDeputyName is null, plussing it with a string text results in NULL.


--
Bas Cost Budde

Nov 12 '05 #6
rkc

"Bas Cost Budde" <ba*@heuveltop.org> wrote in message
news:bv**********@news2.solcon.nl...
Welcome.
Not a native english speaker, I'd like to understand the 'feel' conveyed
by Jist. Would you like to tell me the short story?

Keldar wrote:
I think I get your Jist...


The correct spelling is gist.

http://dictionary.reference.com/search?q=gist
Nov 12 '05 #7
Thanks.
Amazing. That reference would likely eat up all my spare time on the Net...
http://dictionary.reference.com/search?q=gist


--
Bas Cost Budde

Nov 12 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Daniel Bergquist | last post by:
Consider the following chunk of code: -------------------------------------------------- open (IN, "<:raw", "test2.txt") or die "Can't open test.txt"; chomp($line = <IN>); # Capture excerpt...
13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
5
by: Andrew Chanter | last post by:
Does anyone know a way you can use conditional formatting to create a banded style view as is commonly seen on the internet. (In othe words the first record appears on a gray background, the 2nd...
1
by: ammarton | last post by:
Hello all...I'm a bit new to working with Macros in Access so forgive me if the terminology I use is not accurate. To preface this, basically I am using a form on a replicated database so the...
5
by: Trapulo | last post by:
I'm using conditonal compile with statement #IF CONFIG This works if I use #IF CONFIG = "Debug" or #IF CONFIG= "Release" But if I define an other compilation profile, eg. "BestRelease", and I use...
6
by: GAC | last post by:
I've used conditional formatting on ACCESS reports but have come up with a problem using it for a FIELD that has a value of either YES or blank/null. The default formatting (used when condition(s)...
10
by: afromanam | last post by:
Regards, Please help What I'm trying to do is this: (and I can't use reports since I must export to Excel) I export some queries to different tabs in an excel workbook I then loop through...
8
by: banderson | last post by:
Hello, I have a combo box in which I want to display multiple fields by concatenating the fields together. If one of those concatenated fields is Null, then the combo box does not show anything. To...
3
by: summerlw | last post by:
Access 2003 VB 6.5 I'm attempted to run conditional formatting on a date field based on the value in another field. I've steped through this code and it is recognizing the values correct and is...
1
by: gtslabs | last post by:
I have a report with 2 subreports The first subreport has 3 fields (Expr1, Field1, Field2) Where Expr1 is a Date I want to highlight the 3 fields if a date is within a range of 2 dates. I was...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.