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
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