Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

concatenation and trim blanks? 1

Status
Not open for further replies.

kimmole

Technical User
May 9, 2002
49
GB
i,m trying to get a report/query to concatenate fields, place carriage returns after each field and print with no blank lines..... it drives me cwazzzzzzy!!
any ideas?
 
Hi

Have not tried code below, because my copy of Access has just died on me, but I think it will work:

X:=Trim(Field1) & IIF(Len(Trim(Field1))=0,"",vbcrlf) & Trim(Field2) & IIF(Len(TRim(Field2))=0,"",vbcrlf)...etc
Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
tanks ken looks good to me.... i'll go and try it!!

thanks again
 
Ken,
As always, a great tip!!!!! Another star for your helpful posts.
Randy HTH, [pc2]
Randy Smith
California Teachers Association
 
definatly does the concatenation now all i need isa the char for a carriage return and a space between concatenated filds...
so mrkimmole6foundrysquare

comes out...

mr kim mole
6 foundry square
 
thanks again ken....
i'll use the chr bits as i havent a clue what you're on about asregards the vb bit....
....sorry i still use macros
but i'll hget there
ta again kimbo:)))))
 
er ken..... i get a square symbol when i use chr (13) or chr(10)
i've seen the square symbol come in in imported asci text before so mi guess i'm using the wrong symbol for a carriage return...
so far i,ve got....
=Trim([Home Address]) & IIf(Len(Trim([Home Address]))=0,"",Chr(13)) & Trim([Address]) & IIf(Len(Trim([Address]))=0,"",Chr(13)) & Trim([City]) & IIf(Len(Trim([City]))=0,"",Chr(13)) & Trim([State]) & IIf(Len(Trim([State]))=0,"",Chr(13)) & Trim([Zip/Postal Code]) & IIf(Len(Trim([Country]))=0,"",Chr(13)) & Trim([Zip/Postal Code]) & IIf(Len(Trim([Country]))=0,"")
 
i'v now changed it using "is null rather than =0
so...
[x]=Trim([Home Address]) & IIf(Len(Trim([Home Address])) Is Null,"",Chr(13)) & Trim([Address]) & IIf(Len(Trim([Address])) Is Null,"",Chr(13)) & Trim([City]) & IIf(Len(Trim([City])) Is Null,"",Chr(13)) & Trim([State]) & IIf(Len(Trim([State])) Is Null,"",Chr(13)) & Trim([Zip/Postal Code]) & IIf(Len(Trim([Country])) Is Null,"",Chr(13)) & Trim([Zip/Postal Code]) & [Country]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top