By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,495 Members | 1,320 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,495 IT Pros & Developers. It's quick & easy.

Can printer control codes be placed in memo field

100+
P: 114
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.
Jan 10 '07 #1
Share this Question
Share on Google+
6 Replies


nico5038
Expert 2.5K+
P: 3,072
Try:

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

Nic;o)
Jan 11 '07 #2

100+
P: 114
Try:

rs!memofield = replace(rs!memofield,"<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.
Jan 11 '07 #3

nico5038
Expert 2.5K+
P: 3,072
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.openrecordset("name of your table")

while not rs.eof
rs.update
rs!memofieldname = replace (rs!memofieldname,"<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)
Jan 11 '07 #4

100+
P: 114
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.
Jan 11 '07 #5

nico5038
Expert 2.5K+
P: 3,072
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)
Jan 11 '07 #6

NeoPa
Expert Mod 15k+
P: 31,662
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.
Jan 12 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.