When i use the following script to merge from access in to a word document it works fine when i merge from the one table from access. i.e (CStr(Forms!sheet1!Client))
However when i try and use two tables from access and add (CStr(Forms!main!Clientname))the script does not work and the word documnet halts at this point,
Any suggustions as to why this occurs would be appreciated.
With objWord
'Make the application visible.
.Visible = True
'Open the document.
.Documents.Open ("\\Linux\Planning\Planning\Informationplanning\Templates\Crowncastle\databasemerge\DCF1.doc"
'Move to each bookmark and insert text from the form.
.ActiveDocument.Bookmarks("Client".Select
.Selection.Text = (CStr(Forms!sheet1!Client))
.ActiveDocument.Bookmarks("Region".Select
.Selection.Text = (CStr(Forms!sheet1!Region))
.ActiveDocument.Bookmarks("feereburse".Select
.Selection.Text = (CStr(Forms!sheet1!feereburse))
.ActiveDocument.Bookmarks("Clientname".Select
.Selection.Text = (CStr(Forms!Main!Clientname))
End With
Set objWord = Nothing
Exit Sub
MergeButton_Err:
'If a field on the form is empty, remove the bookmark text, and
'continue.
If Err.number = 94 Then
objWord.Selection.Text = ""
Resume Next
'If the Photo field is empty.
ElseIf Err.number = 2046 Then
MsgBox "Please add a photo to this record and try again."
Else
MsgBox Err.number & vbCr & Err.Description
End If
Else
MsgBox "Please enter a fee and the DCF date and try again", vbOKOnly + vbInformation
End If
End Sub
However when i try and use two tables from access and add (CStr(Forms!main!Clientname))the script does not work and the word documnet halts at this point,
Any suggustions as to why this occurs would be appreciated.
With objWord
'Make the application visible.
.Visible = True
'Open the document.
.Documents.Open ("\\Linux\Planning\Planning\Informationplanning\Templates\Crowncastle\databasemerge\DCF1.doc"
'Move to each bookmark and insert text from the form.
.ActiveDocument.Bookmarks("Client".Select
.Selection.Text = (CStr(Forms!sheet1!Client))
.ActiveDocument.Bookmarks("Region".Select
.Selection.Text = (CStr(Forms!sheet1!Region))
.ActiveDocument.Bookmarks("feereburse".Select
.Selection.Text = (CStr(Forms!sheet1!feereburse))
.ActiveDocument.Bookmarks("Clientname".Select
.Selection.Text = (CStr(Forms!Main!Clientname))
End With
Set objWord = Nothing
Exit Sub
MergeButton_Err:
'If a field on the form is empty, remove the bookmark text, and
'continue.
If Err.number = 94 Then
objWord.Selection.Text = ""
Resume Next
'If the Photo field is empty.
ElseIf Err.number = 2046 Then
MsgBox "Please add a photo to this record and try again."
Else
MsgBox Err.number & vbCr & Err.Description
End If
Else
MsgBox "Please enter a fee and the DCF date and try again", vbOKOnly + vbInformation
End If
End Sub