vbCrLf - Import from Access - Appears as a square symbol

A

Alan

I am sure I have had this working before however now struggling ...
I have posted the same question to the Access Group, but think this may be a
Word Issue.

I am looking to export a table from Access into a number of MS Word fields
however although the data passes the Chr(13) and/or vbCrLf, this appears in
the Word field as a square symbol rather than taking a new line. (I am unable
to paste it here as this text box recognises it as a CrLf function !!)

I have the Word Object Library referenced and cant seem to find a reason why
this is not allowing me to take a new line for each entry.

Any help would be gratefully appreciated
 
D

Doug Robbins - Word MVP

Without seeing your code, it is hard to tell you exactly how to incorporate
this, but you need to make use of the Replace() function to replace the
Chr(10) which is the square box with nothing

[sometext in the document] = Replace([sometext from Access], Chr(10), "")


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
A

alborg

Doug's right- it would be great to see some of your code...

That said, here's part of a code from one of my projects that cut/pastes
Access data onto a Word document:

'---------------------------------------------------
zz = Nz(Forms![*MEDICAL INFORMATION]![SEX], "") & " " & Nz(Forms![*MEDICAL
INFORMATION]![FNAME], "") & " " & Nz(Forms![*MEDICAL INFORMATION]![LNAME], "")
yy = Nz(Forms![*MEDICAL INFORMATION]![LNAME], "") & MONTH(DATE) & Day(DATE)
& YEAR(DATE)
stLinkCriteria = "Patient Name: " & zz & vbCrLf & "Consult Date: " & DATE &
vbCrLf & "Admission Date: " & IIf(Forms![soap]![Text5] = "" Or
IsNull(Forms![soap]![Text5]), " ", Forms![soap]![Text5]) & vbCrLf &
"Referring Physician: " & IIf(IsNull(Forms![soap]![AFName2]), " ",
Forms![soap]![AFName2]) & IIf(IsNull(Forms![soap]![AddAttend]), " ",
Forms![soap]![AddAttend]) & vbCrLf & "Problem/Chief Complaint: " &
IIf(IsNull(Forms![soap]![problem]) Or Forms![soap]![problem] = "", " ",
Forms![soap]![problem])
With appWord
.ActiveDocument.Bookmarks("Consultsub").Select
.Selection.Text = stLinkCriteria
strtotal2 = "Work Phone: " & IIf(IsNull(Forms![PERSMDSU]![PWPHONE]), " ",
Forms![PERSMDSU]![PWPHONE]) & "; Fax Phone: " &
IIf(IsNull(Forms![PERSMDSU]![PFPHONE]), " ", Forms![PERSMDSU]![PFPHONE]) & ";
Email: " & IIf(IsNull(Forms![PERSMDSU]!), " ",
Forms![PERSMDSU]![EMAIL])
.Selection.Text = Xx & Chr(13) & SQLStmt & Chr(13) & str & Chr(13) &
strtotal1 & Chr(13) & strtotal2
End With
'--------------------------------------------------

The vbCrLf and chr(13) work just fine there; what you might do also is:

1) Check your references. Are your references all there? Some may be
unchecked or "MISSING", especially the latest Microsoft DAO Object Library
that you have on your machine.
2) Grant it, this has never happened to me, so I've never had to resort to
this fix, but I remember a fix mentioned elsewhere- if the vbCrLf's vbCr part
causes a little rectangle to be displayed, you can use vbLf instead of
vbCrLf.
3) You can also try "vbnewline".

Cheers,
Al

[QUOTE="Doug Robbins - Word MVP"]
Without seeing your code, it is hard to tell you exactly how to incorporate
this, but you need to make use of the Replace() function to replace the
Chr(10) which is the square box with nothing

[sometext in the document] = Replace([sometext from Access], Chr(10), "")


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top