Results 1 to 4 of 4
  1. #1
    Rubijon is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Oct 2011
    Posts
    5

    Conatenate fields and also remove blanks

    Hello,

    First off thanks for taking the time to read this and bare with me as I'm relativly new to access.

    So, how would I go about concatenating multiple fields for a report and also leave out empty fields?

    I would like to concatenate an address

    The fields are
    SiteAddress (text)
    SiteSuburb (text)
    SiteState (number - combo box)
    SitePostcode (number)

    So far I have come up with =[CentreAddress] & ", " & [CentreAddressSuburb] & ", " & [CentreAddressState] & ", " & [CentreAddressPostcode]

    Which gives me: 55 River Street, Maclean, 1, 2463
    How do I make the 1 = NSW?

    Also if the suburb is blank it will look like this
    55 River Street,, 1, 2463



    How would I go about fixing both those issues?

    Thanks for your time.

  2. #2
    Stingaway is offline Efficiency Junkie
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    The deep south. Keep going until you hit water basically.
    Posts
    224
    Ok, first off if this is a query, then you could say IIF([SiteState] = 1, "NSW", [SiteState]) - or replace that final [SiteState] with whatever you want to be there if the number is NOT a 1.

    If it is a report, in your query you should reference a table for SiteStates, link it, and pull down the corresponding field for the name of the site state instead of the number.

    You are on the right track with concatenations, if you want the blanks to disappear, try putting a trim statement on the fields.

    Here is an example of one I use for an address field on a report:

    =(Trim([Fname]) & " " & Trim([Lname]) & Chr(13) & Chr(10)) & ([Address1]+Chr(13)+Chr(10)) & ([Address2]+Chr(13)+Chr(10)) & ([City]) & " , " & ([State]) & " " & ([Zip])

    The Chr(13) and the Chr(10) give me a new line if I remember correctly...

    Hope this helps.

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You might also tell us the SQL for the RowSource of the SiteState ComboBox and maybe there is another option for that element.

  4. #4
    Rubijon is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Oct 2011
    Posts
    5
    Quote Originally Posted by Stingaway View Post
    =(Trim([Fname]) & " " & Trim([Lname]) & Chr(13) & Chr(10)) & ([Address1]+Chr(13)+Chr(10)) & ([Address2]+Chr(13)+Chr(10)) & ([City]) & " , " & ([State]) & " " & ([Zip])

    The Chr(13) and the Chr(10) give me a new line if I remember correctly...

    Hope this helps.
    Thank you both for replying.

    This works a treat! Thanks so much.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Try to remove everything to the right of SF
    By murphy in forum Queries
    Replies: 2
    Last Post: 09-15-2011, 03:20 PM
  2. Fill in blanks from another table
    By HectorH in forum Queries
    Replies: 1
    Last Post: 08-26-2011, 05:13 PM
  3. SQL Update with blanks
    By Tyork in forum Programming
    Replies: 1
    Last Post: 12-17-2010, 10:12 AM
  4. Access filter does not show blanks
    By Jaricketts in forum Access
    Replies: 1
    Last Post: 03-26-2010, 05:38 PM
  5. Adding columns that contain blanks.
    By Tony McGuire in forum Access
    Replies: 11
    Last Post: 05-31-2009, 12:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums