• Access Query Combine Fields (AccessXP)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Access Query Combine Fields (AccessXP)

    Author
    Topic
    #402747

    I have a query that includes the fields City, St and Zip. I want to combine them into one field.

    If I put [city]+[st]+[zip], it works fine IF there is data in ALL 3 fields. But if data is missing in any of the fields nothing happens and it comes up blank.

    Any hints so I get results even with 1 or 2 fields empty?

    Thanks.

    Viewing 1 reply thread
    Author
    Replies
    • #804092

      This is a peculiarity of + that can be very handy, but not in your situation. Use & to concatenate; you will probably want to insert commas and spaces too.

      Very simple:
      [city] & “, ” & [st] & ” ” & [zip]

      Slightly more complicated, combining & and +:
      [city] & (“, “+[st]) & (” “+[zip])

      • #804098

        Thanks! Didn’t know about using &. And yes I was going to put in commas and spaces but they weren’t the problem – the lack of info was. Appreciate your prompt reply. Now I’ll get to work and put it all to work!

      • #804099

        Thanks! Didn’t know about using &. And yes I was going to put in commas and spaces but they weren’t the problem – the lack of info was. Appreciate your prompt reply. Now I’ll get to work and put it all to work!

    • #804093

      This is a peculiarity of + that can be very handy, but not in your situation. Use & to concatenate; you will probably want to insert commas and spaces too.

      Very simple:
      [city] & “, ” & [st] & ” ” & [zip]

      Slightly more complicated, combining & and +:
      [city] & (“, “+[st]) & (” “+[zip])

    Viewing 1 reply thread
    Reply To: Access Query Combine Fields (AccessXP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: