Results 1 to 9 of 9
  1. #1
    plengeb is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    20

    vbCrLf / + Chr(13) + Chr(10) Carriage Returns in A Report

    = "HX: PF | EPF | DET | COMP" + Chr(13) + Chr(10) & "EX: PF | EPF | DET | COMP"

    I am storing the above string in a table. The forms and reports are currently displaying the string exactly as above (I enclosed a pdf file, and the text I’m referring to is in red). When a form or report pulls the field, I would like it to do the carriage returns and appear as below.

    HX: PF | EPF | DET | COMP"
    EX: PF | EPF | DET | COMP

    Does anyone know of a way to get the forms and reports to recognize the carrage returns?



    Thanks a bunch.

    Bill
    Attached Files Attached Files

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Have you tried referencing the field name in your expression?

    =[FieldName]

  3. #3
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    So what you want is saving the evaluated string with the character of vbCrLf, but you don't evaluate your expression. How do you save the value to the table? Using VBA or by simply editing the table in table view? Is multi row enabled for the field you save the value to? Do you want to evalute the code every time the report is generated or only once and directly store the evaluated value in the table?

  4. #4
    plengeb is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    20
    I use VBA to load the data into the table. If the evaluated value can be stored in the table, that would be great

  5. #5
    plengeb is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    20
    I have not tried referencing the field name. I will give it a try.

  6. #6
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    Can you pleace post the vba code you use for storing the data?

  7. #7
    plengeb is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    20
    This is where I am evaluating if I’m storing the string or a null value.
    If Trim(rsUnivSample.Fields(10)) >= "99201" And Trim(rsUnivSample.Fields(10)) <= "99350" Then
    ReasonHold = "'HX: PF | EPF | DET | COMP + Chr(13) + Chr(10) & EX: PF | EPF | DET | COMP + Chr(13) + Chr(10) & MDM: SF | LOW | MOD | HIGH'"
    Else
    ReasonHold = "''"
    End If


    This is where I am inserting the data. The variable in concern is bolded below.
    sql2 = "insert into UniversePreSample values (" _
    & "'" & rsUnivSample.Fields(0) & "',''," _
    & rsUnivSample.Fields(1) & "," _
    & "'" & Format(rsUnivSample.Fields(2), "DD-MMM-YYYY") & "'," _
    & "'" & Format(rsUnivSample.Fields(3), "DD-MMM-YYYY") & "'," _
    & "'" & rsUnivSample.Fields(4) & "'," & rsUnivSample.Fields(5) & "," _
    & "'" & rsUnivSample.Fields(6) & "','" & rsUnivSample.Fields(7) & "'," _
    & "'" & rsUnivSample.Fields(8) & "','" & rsUnivSample.Fields(9) & "'," _
    & "'" & rsUnivSample.Fields(10) & "'," _
    & "'" & rsUnivSample.Fields(11) & "'," _
    & "'" & rsUnivSample.Fields(12) & "'," _
    & "'" & rsUnivSample.Fields(13) & "'," _
    & "'" & rsUnivSample.Fields(14) & "'," _
    & rsUnivSample.Fields(15) & "," _
    & rsUnivSample.Fields(16) & "," _
    & rsUnivSample.Fields(17) & "," _
    & "'" & Format(rsUnivSample.Fields(18), "DD-MMM-YYYY") & "',''," _
    & "'" & rsUnivSample.Fields(19) & "','','','','','','',''," _
    & rsUnivSample.Fields(20) & "," _
    & "'','',''," & rsUnivSample.Fields(21) & ",'','','','','','','','','','','',''," _
    & "'" & rsUnivSample.Fields(22) & "'," _
    & "'" & rsUnivSample.Fields(23) & "','','','','','','','','','','','','','','',' '," _
    & "'" & rsUnivSample.Fields(24) & "','" & rsUnivSample.Fields(25) & "'," _
    & ReasonHold & ",0,0,0,0,0,'',0,0,0,0,0,'',0,0,0,0,0," _
    & "''," & Position & ",'','','','',''," & RecipClmPos & ",'','','','','','','','N','N','')"
    dbsample.Execute (sql2)

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    This is VBA

    Code:
    If Trim(rsUnivSample.Fields(10)) >= "99201" And Trim(rsUnivSample.Fields(10)) <= "99350" Then
    ReasonHold = "'HX: PF | EPF | DET | COMP + Chr(13) + Chr(10) & EX: PF | EPF | DET | COMP + Chr(13) + Chr(10)  & MDM: SF | LOW | MOD | HIGH'"
     Else
              ReasonHold = "''"
     End If
    It does not match what you posted earlier
    Code:
    = "HX: PF | EPF | DET | COMP" + Chr(13) + Chr(10) & "EX: PF | EPF | DET | COMP"
    In your If Else statement, concatenate like you did in post #1 or.....
    = "HX: PF | EPF | DET | COMP" & vbcrlf & "EX: PF | EPF | DET | COMP"

  9. #9
    plengeb is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    20
    Thank you so much to everyone that responded. I found a solution on another forum that works, and I want to share it, with the hopes that it will help you in the future. The solution is to use the break code like you use for html, and then set the field on the report to Rich Text. The Rich Text enables the html to be interpreted.

    HX: PF | EPF | DET | COMP<Br>EX: PF | EPF | DET | COMP<Br>MDM: SF | LOW | MOD | HIGH

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

Similar Threads

  1. Export Fixed Width with No Line Breaks/Carriage Returns
    By jpfulton248 in forum Import/Export Data
    Replies: 5
    Last Post: 01-17-2014, 12:41 PM
  2. Replies: 15
    Last Post: 08-12-2013, 07:27 PM
  3. Replace Carriage Returns with Spaces
    By chitan in forum Queries
    Replies: 1
    Last Post: 12-15-2011, 11:14 AM
  4. Removing all carriage returns from a database
    By Yesideez in forum Access
    Replies: 2
    Last Post: 06-26-2011, 09:55 AM
  5. Help with & vbCrLf
    By darklite in forum Access
    Replies: 2
    Last Post: 09-02-2010, 10:24 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