Results 1 to 12 of 12
  1. #1
    jlindquist23 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jan 2019
    Posts
    46

    Text field missing carriage returns

    I'm pulling data from an ODBC table in Sage 100. When the data is viewed in a report in Access, all the carriage returns are ignored and all the text runs together.
    Is there a way to resolve this? When I use this same data in Crystal Reports, it prints as it looks in Sage 100. All 3 examples shown below.

    SAGE text:
    Click image for larger version. 

Name:	Sage.jpg 
Views:	20 
Size:	34.2 KB 
ID:	53316



    Crystal Reports:

    Click image for larger version. 

Name:	CR.jpg 
Views:	20 
Size:	30.7 KB 
ID:	53317
    MSAccess:
    Click image for larger version. 

Name:	Access.jpg 
Views:	20 
Size:	30.9 KB 
ID:	53315

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    I would look to see what characters are meant to be the linefeed/carriage return.
    Then replace those with vbCrLf
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    To find out what those characters are, you might need to paste the original content into Word. I think it's Show/Hide in the paragraph group on the ribbon that will show you hidden characters.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    pass your string to this function and see results in the immediate window

    Code:
    Function AscChar(s As String, Optional startpos As Long = 1, Optional maxchars As Long = 0)
    Dim i As Long
    
    
        If Len(s) > 0 Then
        
            If maxchars = 0 Or (maxchars + startpos) > Len(s) Then maxchars = Len(s) - startpos
            For i = startpos To startpos + maxchars
                Debug.Print Mid(s, i, 1) & " - " & Asc(Mid(s, i, 1))
            Next i
            
        End If
        
    End Function

  5. #5
    jlindquist23 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jan 2019
    Posts
    46
    Adding to Word:
    Click image for larger version. 

Name:	word.jpg 
Views:	15 
Size:	51.2 KB 
ID:	53319

    Using the function with a control in the report, the output is:
    Click image for larger version. 

Name:	function.jpg 
Views:	15 
Size:	3.7 KB 
ID:	53320

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    I cannot see how that function produced that output?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    jlindquist23 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jan 2019
    Posts
    46
    I'm using this in my query:
    Setup Instructions: Replace(Replace([ExtendedDescriptionText],Chr(13),Chr(13) & Chr(10)),Chr(10),Chr(13) & Chr(10))
    Can Grow and Can Shrink are set at Yes.
    Text format is set at Plain Text.
    The only issue now is that it truncates the information:
    Click image for larger version. 

Name:	truncate.jpg 
Views:	14 
Size:	21.7 KB 
ID:	53321

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    It would if they used the maxchars parameter of 6

    OP should really show the code they used

  9. #9
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Except your code uses dash as a separator but the results show = sign?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    * is 42, where is the rest?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #11
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    Good spot 😀

  12. #12
    jojowhite's Avatar
    jojowhite is online now Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    maybe create a Function in a Module:
    Code:
    Public Function FixCrLf$(Byval sText$)
    sText = Replace$(sText,Chr$(13), Chr$(13) & Chr$(10))
    sText = Replace$(sText,Chr$(10), Chr$(13) & Chr$(10))
    Do While Instr(1, sText, Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10)) <> 0
        sText = Replace$(sText, Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10), Chr$(13) & Chr$(10))
    Loop
    FixCrLf = sText
    End Function
    From your Query:
    Code:
    Setup Instructions: FixCrLf([ExtendedDescriptionText] & "")

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

Similar Threads

  1. Replies: 10
    Last Post: 12-13-2015, 07:23 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