Re: Concatenation

From: Graham Mandeno (Graham.Mandeno_at_nomail.please)
Date: 03/11/04


Date: Fri, 12 Mar 2004 12:30:49 +1300

You can use a nifty little trick here which utilises the difference between
the & and the + operators.

"some string" & Null results in "some string"
"some string" + Null results in Null

So, you can make an expression like this:

NameAndAddress: FirstName & (" " + MI) & Last_Name & (", " + Suffix)
    & (Chr(13) + Chr(10) + Address_1)
    & (Chr(13) + Chr(10) + Address_2)
    & (Chr(13) + Chr(10) + Address_3)

This will only add the extra literal strings (blank before MI, ", " before
Suffix and new line before each address line) if there is data in those
fields.

-- 
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand - Home of Lord of the Rings
"BradleyJ" <anonymous@discussions.microsoft.com> wrote in message
news:A0114937-8292-4F53-9041-3BA0B6463BD1@microsoft.com...
> I have a query that returns the following fields -  First_Name, MI,
Last_Name,Suffix, Address_1, Address_2, Address_3, as well as others.
> I want to concatenate the name fields and address fields.  I created an IF
statement that look like is should work but its not.  Now there may not be
data in several of the fields.  When I use my IF I get syntax, oerpand
errors.  I since have made 3 of the 4 name fields required entry, but that
leaves the address fields.  What I want is that if Add_3 is null give me
Add_1, Add_2, If Add_2 is null I just want Add_1, ia all three have valuse I
want all three.  I hope this is clear.  For the life of me I can't figure
out where I'm going wrong.  Please help, this is urgent


Relevant Pages

  • A neat trick to serialize arrays and hashes
    ... who thinks that my trick is "obvious to everyone but inexperienced ... hashes -- that is, it can pack and unpack arrays and hashes to and ... I might want to serialize @a into a string for the purpose of storing ... array into a string like so: ...
    (comp.lang.perl.misc)
  • Re: Efficient use of results of [binary scan]
    ... And memory allocation is *definitely* comparatively slow ... The same trick is ... naif solution, for my 100K string. ... DOULOS - Developing Design Know-how ...
    (comp.lang.tcl)
  • Re: Fetch function names & prototypes?
    ... > although in C++ the prototypes are found in the header files included ... > string into the object file symbol table, ... trick would not allow a perfect/accurate type checking. ... arguments have complex data types, ...
    (comp.compilers)
  • Re: Newbie: Convert String to Symbol?
    ... But I'm missing the conversion from string to symbol! ... (defmacro defop (symbol function) ... this "trick" is very nice when mapping assembler ...
    (comp.lang.lisp)
  • parsing an xml string into fields
    ... I'm getting a small xml file as on big string and need to parse it into it's fields for use. ... Can anyone point me to a nifty way to do this in .net? ...
    (microsoft.public.dotnet.languages.vb)