hawkingsright
New member
- Local time
- Today, 15:22
- Joined
- Mar 15, 2013
- Messages
- 6
I have a problem with passing data to a word form for quoting customers. This works fine, but the Item Description and Pricing values won't transfer past the first entry. Any help would be greatly appreciated. Here's the code:
Code:
Dim appWord As Word.Application
Dim doc As Word.Document
Dim rst As ADODB.Recordset
Dim strSQL As String
Dim strReportsTo As String
On Error Resume Next
Set appWord = GetObject(, "Word.application")
If Err = 429 Then
Set appWord = New Word.Application
Err = 0
End If
With appWord
Set doc = .Documents(DOC_NAME)
'If Err = 0 Then
' If MsgBox("Do you want to save the current document " _
' & "before updating the data?", vbYesNo) = vbYes Then
' .Dialogs(wdDialogFileSaveAs).Show
' End If
'doc.Close False
'End If
On Error GoTo ErrorHandler
Set doc = .Documents.Open(DOC_PATH & DOC_NAME, , True)
Set rst = New ADODB.Recordset
With doc
.FormFields("fldCOMPANY").Result = Nz(Me!COMPANY)
.FormFields("fldCITY").Result = Nz(Me!CITY)
.FormFields("fldSTATE").Result = Nz(Me!STATE)
.FormFields("fldCONTACT").Result = Nz(Me!CONTACT)
.FormFields("fldPHONE").Result = Nz(Me!PHONE)
.FormFields("fldFax").Result = Nz(Me!Fax)
.FormFields("fldDESCRIPTIO").Result = Nz(Me!History.Form.DESCRIPTIO)
.FormFields("fldSELL").Result = Nz(Me!History.Form.Sell)
.FormFields("fldSELLBROKEN").Result = Nz(Me!History.Form.SellBroken)
End With
.Visible = True
.Activate
End With
Set rst = Nothing
Set doc = Nothing
Set appWord = Nothing
Exit Sub
ErrorHandler:
MsgBox Err & Err.Description
End Sub