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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing blanks fields from query

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
586
GB
Hello All,

I use the code below to format addresses.

It works generally ok, but sometimes I think an empty field is not picked up as Null and thus carriage return is put in when not required.

Is there a way to modify the code to test for empty as well as null fields?

Many thanks for any help. If someone could modify part of the code this would help greatly as my coding is a little poor.




Address_Multi_line: IIf(Not IsNull([address no]),"" & [address no] & " ","") & IIf(Not IsNull([Address 1]),"" & [Address 1] & "","") & Chr(13) & Chr(10) & IIf(Not IsNull([Address 2]),"" & [Address 2] & "","") & Chr(13) & Chr(10) & IIf(Not IsNull([Address 3]),"" & [Address 3] & "","") & Chr(13) & Chr(10) & IIf(Not IsNull([Address 4]),"" & [Address 4] & "","") & Chr(13) & Chr(10) & IIf(Not IsNull([Address postcode]),"" & [Address postcode] & "","")
 
The following seems to work - it it ok - or should I be doing something better?

Thanks Mark

Address: IIf([address no]<>"","" & [address no] & " ","") & IIf([address 1]<>"","" & [address 1] & "","") & IIf([address 2]<>"","" & ", " & [address 2] & "","") & IIf([address 3]<>"","" & ", " & [address 3] & "","") & IIf([address 4]<>"","" & ", " & [address 4] & "","") & IIf([address postcode]<>"","" & ", " & [address postcode] & "","")
 
Replace this:
Not IsNull([address XX])
with this:
Trim([address XX] & "")<>""

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top