Can printer control codes be placed in memo field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ljungers
    New Member
    • Dec 2006
    • 114

    Can printer control codes be placed in memo field

    I have a memo field that is printed using Access Reports. Various fields from this table are used to fill in the heading and the body of the report uses that memo field.

    I now need to place some CR's & LF's into this memo so that the report is easy to read. I know that I can place the CR's into the ASCII text file before I import, but LF's I cannot because that affects the number of records loaded. I placed the characters <crlf> to indicate where these codes are needed.

    I have tried to use the Find/Replace to change this <crlf> into the required codes but I can't insert hex codes (Alt + decimal number) into the replace field, or is there another way to handle the replace field.

    Can LF's be inserted into the memo without affecting the memo field? Is there an easy way to do this if LF's are allowed, or is this something that only a VBA script can accomplish?

    Thanks for any information on this.
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Try:

    rs!memofield = replace(rs!memo field,"<crlf>", chr(13) & chr(10))

    Nic;o)

    Comment

    • ljungers
      New Member
      • Dec 2006
      • 114

      #3
      Originally posted by nico5038
      Try:

      rs!memofield = replace(rs!memo field,"<crlf>", chr(13) & chr(10))

      Nic;o)
      Where should this command be placed? In a VBA, query, or is this something that can be run on the fly.

      Will try to run it this afternoon.

      Comment

      • nico5038
        Recognized Expert Specialist
        • Nov 2006
        • 3080

        #4
        Depends when or where you want to change the data.

        As memo fields are truncated in queries I prefer to use a VBA function like:

        function fncReplaceMemo( )

        dim rs as DAO.recordset

        set rs = currentdb.openr ecordset("name of your table")

        while not rs.eof
        rs.update
        rs!memofieldnam e = replace (rs!memofieldna me,"<crlf>",chr (13)&chr(10))
        rs.update
        rs.movenext
        wend

        end function

        Just modify the tabel and fieldname and press F5 to run the code when the cursor is within a line of the function code.

        Nic;o)

        Comment

        • ljungers
          New Member
          • Dec 2006
          • 114

          #5
          One last question.

          Should this code be placed in a module and run the way you described or in the code of a form that uses this memo field. The code makes sense to me as I look at it, but just not sure where and how.

          Thanks for the help.

          Comment

          • nico5038
            Recognized Expert Specialist
            • Nov 2006
            • 3080

            #6
            The function is for a once off conversion of an entire table.When you have a form you can set the Enter key behaviour in the properties window (under Other tab) for the memofield to "New line" and save the trouble of the Replace()

            Nic;o)

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32633

              #7
              Just to mention (FYI), the characters for CR; LF & CRLF are set up in VBA as pre-defined strings VbCr; VbLf & VbCrLf respectively.
              The concepts are just as Nico has outlined but using the predefined strings should make it a little easier (to understand if not to wrte).
              HTH.

              Comment

              Working...