Results 1 to 11 of 11
  1. #1
    TedT is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    10

    Getting carriage returns in address field to print on labels

    Hi,
    I have a large database of contacts (7000+) that has 1 field for the address (was setup years ago this way and moved to Access later). In Access, each address line is separated with a carriage return so an address may have as many lines as needed - typically 2 lines - street, then city+state+zip, international will have a third line with the country, etc.


    I am trying to print mailing labels, and all the addresses show up on 1 line, so the post office will not handle them.
    I can't seem to figure out why the carriage returns are being ignored in the field and I hope there is someway to make this work, otherwise I will need to hand write all the labels.
    Thanks
    Ted T

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Please show some sample data, so readers can "test" their ideas.
    If you have some code to process the addresses, you should post that as well.

  3. #3
    TedT is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    10
    I have no code, I used the label wizard. Not sure what data I can send, but it is pretty straight forward.

    I have 1 field called address. In this field, the data is entered with carriage returns so on any form etc it looks like this:
    mystreet
    city, state, zip
    country

    So 3 separate lines.

    The label wizard prints that field as:
    mystreet city, state, zip country
    all on one line.

    I cannot go through 7000 records to split the address field into separate fields so I can arange the label - I only have the "address" field to print and it needs to be formatted as it appears everywhere else.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    I cannot replicate this issue. I built a report with the label wizard and the multi-line address shows as multiple lines. I used two methods to create the carriage returns and results are same:

    1. ctrl + Enter

    2. setting textbox EnterKeyBehavior for new line

    This data should be in separate fields. If you really do have carriage return codes in the data, splitting into 3 parts should be quite easy. Then if the City/State/Zip really has commas, again should be easy to split. A VBA procedure could accomplish this - run it once and data is fixed and never have to do again as long as new data is entered correctly. Even a series of UPDATE queries could do this, without VBA.
    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.

  5. #5
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    Have you tried doing a replace?

    replace(fieldname, chr(10) & chr(13), " ")

    The worst you'd get is an extra space at the end of your address.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Xippooo, correct order of codes for CR & LF is Chr(13) & Chr(10).

    But how would replacing with a space force multi-line display?
    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
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    Quote Originally Posted by June7 View Post
    Xippooo, correct order of codes for CR & LF is Chr(13) & Chr(10).

    But how would replacing with a space force multi-line display?
    It looks like I misread the OP. I thought it was a little odd that they would want it to be on one line.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    For what its worth I mocked up a couple of addresses. I entered the data directly into the table (tblMockAddresses) and used Ctrl Enter to enter CrLf's.

    The data is shown in the graphic along with the 2-up labels I created using the Label wizard directly on the table.


    To ensure the input data actually contained CrLF Chr(13) Chr(10), I used this routine
    Code:
    Sub testdec12()
        Dim x As Variant, i As Integer
        Dim rs As DAO.Recordset
        Set rs = CurrentDb.OpenRecordset("tblMockAddresses")
        Do While Not rs.EOF
            x = Split(rs!ADDRLINE, Chr(13) & Chr(10))
            For i = LBound(x) To UBound(x)
                Debug.Print rs!id; i; x(i)
            Next i
            rs.MoveNext
        Loop
    End Sub

    and got this output

    Code:
     1  0 27 Smith St.
     1  1 Kingston, Ontario
     1  2 CANADA
     2  0 2200 Lake Clark Drive
     2  1 Lake Worth
     2  2 Florida, USA,   33461
    Since this data is meant to represent the OP's data, and since it works for me, I think there must be something the OP hasn't told us, or isn't aware of.
    Attached Thumbnails Attached Thumbnails AddrLabel.jpg   tblMockAddresses_design.jpg  

  9. #9
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Hmmm, maybe using a textbox control's Text Format property to = Rich Text (located under the Data tab of the Property Sheet) would be beneficial.

  10. #10
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    I think there must be something the OP hasn't told us,
    I think he has
    each address line is separated with a carriage return
    And as all responders are saying - it should be carriage return and line feed

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    As suggested in post 2, show us some real data. We can only guess at what the OP is dealing with.

    If the OP has a text line followed by chr(13) only, then he could replace chr(13) with chr(13) & chr(10).
    We need to hear from the OP.

    So simple to test --with sample data.
    ??? Did his data ever produce labels???

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

Similar Threads

  1. Replies: 5
    Last Post: 12-15-2014, 03:34 AM
  2. Replies: 2
    Last Post: 07-09-2014, 06:41 PM
  3. Replies: 15
    Last Post: 08-12-2013, 07:27 PM
  4. Replace Carriage Returns with Spaces
    By chitan in forum Queries
    Replies: 1
    Last Post: 12-15-2011, 11:14 AM
  5. Removing all carriage returns from a database
    By Yesideez in forum Access
    Replies: 2
    Last Post: 06-26-2011, 09:55 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