Results 1 to 8 of 8
  1. #1
    CP611 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    57

    Moving onto a different line by a comma

    Hello,


    I'm a beginner. Have set up a query to convert one set of data into another. I have an address field which is called Street Address in the input file and an example in here is 6 station road, London. I want to write a query that will cause the output to use a comma to move whatever is after it onto a different line, remove the leading space and ensure all in leading capitals so it would show as the below in the output file to export into Excel.

    6 Station Road
    London

    Thank you!

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    I would look at the replace function and StrConv functions.

    You want to replace ", "
    with Chr(10) & Chr(13) - These represent a carriage return.

    Replace([YourField],", ", Chr(10) & Chr(13) )
    StrConv([YourField],3) - This will convert to Proper Case

    You can combine them once they are giving you the correct results.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    CP611 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    57
    Hello, thats great thank you. How would you combine the two together?

  4. #4
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Do this in a straight forward select query before committing to changing anything.

    Code:
    Select [YourField] , StrConv(Replace([YourField],", ", Chr(10) & Chr(13) )) as NewFieldValue
     from [YourTable]
    That will show you before and after values.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    You should consider breaking up addresses into their component parts, StreetNumber, StreetName, City, State, Zipcode, etc. Whatever works for a UK address.
    You can then use the Law of Propagating Nulls (Anything Plus(+) a null is null) to format the address anyway you want.
    something like - (StreetNumber + " ") & (StreetAddress + vbNewLine) & (City + vbNewLIne) - note the uses of + and &.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Agree address components should be in separate fields to facilitate filtering and sorting.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Notwithstanding other suggestions, I think the correct order for chr function is chr(13) & chr(10).
    Fairly certain that it matters.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    Minty is offline VIP
    Windows 11 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Quote Originally Posted by Micron View Post
    Notwithstanding other suggestions, I think the correct order for chr function is chr(13) & chr(10).
    Fairly certain that it matters.
    Yup, you are dead right, I would edit my posts but I'm too late...
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Replies: 12
    Last Post: 01-30-2019, 12:33 PM
  2. Moving Statistics below profit line on a report
    By Bill Singh in forum Access
    Replies: 1
    Last Post: 08-07-2014, 11:13 AM
  3. Subform moving line and label
    By hawkins in forum Reports
    Replies: 1
    Last Post: 08-16-2011, 11:15 PM
  4. Replies: 7
    Last Post: 04-11-2011, 03:58 PM
  5. Converting Access database form onto a web page
    By nosirrah69 in forum Database Design
    Replies: 2
    Last Post: 03-07-2006, 05:06 AM

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