Combine two fields

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

There are two fields A and B where A is returned by a
function.

We would like to display A only if B is null OR empty.
And display A/B if B is not empty.
Like:
A = "BB34/2005"
B = "C"
--> Display "BB34/2005/C"

A = BB35/2005
B = Empty or Null
--> Display "BB35/2005"

Thanks
 
There are two fields A and B where A is returned by a
function.

We would like to display A only if B is null OR empty.
And display A/B if B is not empty.
Like:
A = "BB34/2005"
B = "C"
--> Display "BB34/2005/C"

A = BB35/2005
B = Empty or Null
--> Display "BB35/2005"

Thanks

In your query put a calculated field:

Display: [A] & ("/" + )

The + operator propagates NULLS, so if is NULL then ("/" + ) is
also NULL. The & operator also concatenates strings, but treats a NULL
as a zero length string.

John W. Vinson[MVP]
 
Dear John,

Thank you for your advice.

Peter
-----Original Message-----
There are two fields A and B where A is returned by a
function.

We would like to display A only if B is null OR empty.
And display A/B if B is not empty.
Like:
A = "BB34/2005"
B = "C"
--> Display "BB34/2005/C"

A = BB35/2005
B = Empty or Null
--> Display "BB35/2005"

Thanks

In your query put a calculated field:

Display: [A] & ("/" + )

The + operator propagates NULLS, so if is NULL then ("/" + ) is
also NULL. The & operator also concatenates strings, but treats a NULL
as a zero length string.

John W. Vinson[MVP]
.
 
If this is in a query, maybe you could create a calculated field with
an expression along these lines:

=IIF(IsNull(B) or B Like "", A, A & "/" & B)


Mark
(e-mail address removed)(no dashes)
http://access-pro.tripod.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top