Sending info from a memo field in access to a form field in word

Cpowell

Registered User.
Local time
Today, 04:15
Joined
May 20, 2009
Messages
10
Hello,

I have a database used to enter client information which then outputs all of that data as necessary to various word documents via form fields. I cannot use anything other than word documents as these are HQ designed forms and they get upset when they are modified. (took forever to get permission to put in form fields instead of making people type into the docs directly) The only problem I am having is one of the forms is a memo whic goes in the clients file. My office loves the database and wants me to make it so the memo is stored in the database as well. I had no problems with this using a memo field. The problem is that when I use the following code:

Private Sub Command5_Click()
Dim appWord As Word.Application
Dim doc As Word.Document
Dim strSQL As String
Dim strReportsTo As String
Dim fullpath As String
On Error Resume Next
Set appWord = CreateObject("Word.Application")

With appWord
Set doc = .Documents(MEMOTOFILE.dot)

Set doc = .Documents.Add(Template:=BackEnd & "\Forms\MEMOTOFILE.dot", newtemplate:=False, Documenttype:=0)

With doc
.FormFields("Clientnumber").Result = (Me!Clientnumber) & ""
.FormFields("Name").Result = (Me!FirstName) & " " & (Me!MiddleName) & " " & (Me!LastName) & ""
.FormFields("CompanyNumber").Result = (Me!IDnumber) & " " & (Me!IDFirstName) & " " & (Me!IDLastName) & ""
.FormFields("Memo").Result = (Me!Memo) & ""
End With
.Visible = True
.Activate
End With

Set rst = Nothing
Set doc = Nothing
Set appWord = Nothing
DoCmd.Close acForm, Me.Name
Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click
End Sub

I onlt get up to 255 characters and if there s more in the memo field than that it won't put anything in the word form field.

I tried this with several form fields:

Private Sub Command5_Click()
Dim appWord As Word.Application
Dim doc As Word.Document
Dim strSQL As String
Dim strReportsTo As String
Dim fullpath As String
On Error Resume Next
Set appWord = CreateObject("Word.Application")

With appWord
Set doc = .Documents(MEMOTOFILE.dot)



Set doc = .Documents.Add(Template:=BackEnd & "\Forms\MEMOTOFILE.dot", newtemplate:=False, Documenttype:=0)

With doc
.FormFields("Clientnumber").Result = (Me!Clientnumber) & ""
.FormFields("Name").Result = (Me!FirstName) & " " & (Me!MiddleName) & " " & (Me!LastName) & ""
FormFields("CompanyNumber").Result = (Me!IDnumber) & " " & (Me!IDFirstName) & " " & (Me!IDLastName) & ""
.FormFields("Memo").Result = Mid(Me!Memo, 1, 250) & ""
.FormFields("Memo2").Result = Mid(Me!Memo, 251, 500) & ""
.FormFields("Memo3").Result = Mid(Me!Memo, 501, 750) & ""
.FormFields("Memo4").Result = Mid(Me!Memo, 751, 1000) & ""
.FormFields("Memo5").Result = Mid(Me!Memo, 1001, 1250) & ""
.FormFields("Memo6").Result = Mid(Me!Memo, 1251, 1500) & ""
.FormFields("Memo7").Result = Mid(Me!Memo, 1501, 1750) & ""
End With
.Visible = True
.Activate
End With

Set rst = Nothing
Set doc = Nothing
Set appWord = Nothing
DoCmd.Close acForm, Me.Name
Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click
End Sub


But the result for that was that it would only output to two of the form fields the first with information and the last with information. Can someone help me with this?

Thanks
 
to two of the form fields the first with information and the last with information.
what does this mean? WHich fields got what? Be precise -we cannot see your screen or read your mind.

Did you check whether the control on the form indeed contains more than 255 characters? You are probably victim of this feature: http://allenbrowne.com/ser-63.html
 
It always fills in the form field called "memo" and then the one furthers down the line which has information. For instance if the last character is number 758 it will fill "memo" with characters 1 to 250 and "memo3" with 751 to 758, but will not fill anything in "memo2" I do know about that problem and that site having seen that site before, however it does put through more characters than 255 just not the middle ones for some reason. ( I did attempt this with significantly more and when i put in 1115 characters it sent 1 to 250 to "memo" and 1001 to 1115 to "memo5" but left memos 2, 3, and 4 blank.
 

Users who are viewing this thread

Back
Top Bottom