Re: Chr(10) does not produce linefeed in formfield by JGM
JGM
Wed Jan 28 11:22:59 CST 2004
Hi Steve,
It is probably because the people at MS decided to include a little comment
in the online help file, somehting to the effect that Chr(11) is not managed
under Microsoft Windows. At least this is what it says in my online help, on
the page that lists the character codes from 0 to 127.
I never used it because I though it was useless to even try, until someone
suggested I gave it a shot a while back... it might have been Lars!
Cheers!
--
_______________________________________
Jean-Guy Marcil
jmarcil@sympatico.ca
"SteveT" <SteveT8@comcast.net> a écrit dans le message de news:
5fb601c3e5c0$78d0d7a0$a401280a@phx.gbl...
Doug--
Thanks for you efforts, I know you spent some time on my
problem. It may have something to do with sending the
code from an MS Access form. Nothing worked until I
tried the vertical tab, Chr(11), as suggested by Lars-
Eric.
Steve
>-----Original Message-----
>Hi Steve,
>
>Not having your database to use, I set up a document
with a couple of
>formfields with one of them having the bookmark name of
victioms and had a
>macro containing the following code run on exit from
that formfield.
>
>Dim i As Long, oDoc As Document
>Set oDoc = ActiveDocument
>For i = 1 To 10
> If oDoc.FormFields("victims").Result = "" Then
> oDoc.FormFields("victims").Result = "Item" & i
> Else
> oDoc.FormFields("victims").Result =
>oDoc.FormFields("victims").Result & vbCr & "Item" & i
> End If
>Next i
>
>It populated the formfield with
>
>Item1¶
>Item2¶
>....
>....
>Item10¶
>
>That was after I corrected the couple of typos in the
code that I had
>suggested (oDoc and odDoc)
>--
>Please post any further questions or followup to the
newsgroups for the
>benefit of others who may be interested. Unsolicited
questions forwarded
>directly to me will only be answered on a paid
consulting basis.
>Hope this helps
>Doug Robbins - Word MVP
>"SteveT" <SteveT8@comcast.net> wrote in message
>news:4c9301c3e4fe$20148e30$a301280a@phx.gbl...
>I just noticed something peculiar, Doug.
>After I populate the Word document, using your code, the
>result with two records is the first string, a small box,
>then the second string--all on one line.
>
>If I put the cursor in front of the small box character
>and hit ENTER, the second string moves down TWO lines and
>the little box disappears.
>
>In other words, the line feed is there, it just doesn't
>activate. When I place another one in manually, the
>first one activates as well.
>
>On a whim I formatted the field to calculate on exit, but
>that didn't help.
>
>I think we're dealing with a bug.
>
>What do you think?
>
>Steve
>>-----Original Message-----
>>Hi Steve,
>>
>>I am sure that it is not because of your trying to
>insert it into a
>>formfield because if a macro containing the following
>code is run on exit
>>from the formfield "Text1", the result is
>>
>>lineone¶
>>linetwo
>>
>>Instead of trying to build a string containing all of
>the records, you may
>>need to create the document and populate the formfield
>by using
>>
>>
>>Do Until rst1.EOF
>> If oDoc.FormFields("victims").Result = "" then
>> odDoc.FormFields("victims").Result = strVictims
>& "#" & i & "-" &
>>rst1!FullName & " " & rst1!Address & " " & rst1!
txtphone
>> Else
>> odDoc.FormFields("victims").Result =
>>odDoc.FormFields("victims").Result & vbCr &strVictims
>& "#" & i & "-" &
>>rst1!FullName & " " & rst1!Address & " " & rst1!
txtphone
>> End If
>> i = i + 1
>> rst1.MoveNext
>>Loop
>>
>>
>>--
>>Please post any further questions or followup to the
>newsgroups for the
>>benefit of others who may be interested. Unsolicited
>questions forwarded
>>directly to me will only be answered on a paid
>consulting basis.
>>Hope this helps
>>Doug Robbins - Word MVP
>>"SteveT" <SteveT8@comcast.net> wrote in message
>>news:4dd701c3e453$d8667e40$a601280a@phx.gbl...
>>> Thanks, Doug, but that didn't work either.
>>> I'm thinking the problem is that I'm in a form field.
>>>
>>> This is the code I'm using to open a Word template and
>>> automatically populate a form field with information
in
>>> an Access recordset. The recordset is a list of
>>> victims's names, addresses, and phone numbers. I want
>to
>>> loop throught the records, giving a number to each
>>> victim. Usually there's no more than 2 or 3, but I
want
>>> them on separate lines. This information populates a
>>> form field called "Victims" in the Word document.
>>> CODE:
>>>
>>> Dim oDoc As Word.Document
>>> Dim strVictims As String
>>> Dim rst1 As ADODB.Recordset
>>> Dim i As Integer
>>> i = 1
>>> Set rst1 = New ADODB.Recordset
>>> rst1.Open "SELECT entryID, fullname, address,
>>> txtphone " _
>>> & "FROM qryVictimNames WHERE entryID = " &
>>> Me.txtEntryID, _
>>> CurrentProject.Connection
>>> Do Until rst1.EOF
>>> strVictims = strVictims & "#" & i & "-" & rst1!
>>> FullName & " " & rst1!Address & " " & _
>>> rst1!txtphone & Chr(10) 'or vbCR or
>>> everything else I've tried
>>> i = i + 1
>>> rst1.MoveNext
>>>
>>> Loop
>>> rst1.Close
>>> Set rst1 = Nothing
>>>
>>>
>>> Set oDoc = oSupp.Documents.Add
>>> ("Z:\templates\AccessSuppRpt.dot")
>>> With oDoc
>>> .FormFields("victims").Result = strVictims
>>> ' Other formfields are populated similarly..
>>> End With
>>> oSupp.Visible = True
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>Using Office XP I am populating formfields on a Word
>>>>template from a query in Access. Everything works
>fine,
>>>>but when I attempt to do a line-feed, all I get is a
>>>>little box. I have tried both Chr(10) and Chr(13) for
>>>>line feed and carriage return. Other Chr codes work.
>>> Chr
>>>>(36) produces a dollar sign, etc.
>>>>
>>>>How can I do a line feed in a formfield with code?
>>>>
>>>>Thanks in advance.
>>>>
>>>>Steve
>>>>.
>>>>
>>
>>
>>.
>>
>
>
>.
>