Can't quite persuade it to work.

Steven811

Registered User.
Local time
Today, 23:05
Joined
Apr 18, 2004
Messages
133
Hi

Although A2k limits the use of nesting subforms to 3 levels and this increases to 7 for 2002 and 2003 I can't get the code to work.

On another PC I have A2002, I converted the db and it all seems to work fine. When I run the merge I still can't seem to get past the 2nd subform to copy the record set from the final subform.

I have followed the advice from the faq syntax for main and subforms.

Any tips would be very welcome.

Steven811

The full code is as follows:

Code:

Private Sub MergeButton_Click()
On Error GoTo MergeButton_Err

Dim objWord As Word.Application


'Start Microsoft Word.
Set objWord = CreateObject("Word.Application")

With objWord
'Make the application visible.
.Visible = True

'Open the document.
.Documents.Open ("C:\MyMerge.doc")

'Move to each bookmark and insert text from the form.
.ActiveDocument.Bookmarks("CompanyName").Select
.Selection.Text = (CStr(Forms!MainForm!FieldName))


'Move to each bookmark and insert text from the form.
.ActiveDocument.Bookmarks("SiteName").Select
.Selection.Text = (CStr(Me!subForm1.Form!FieldName1))

.ActiveDocument.Bookmarks("cboDesignation").Select
.Selection.Text = (CStr(Me!subForm1.Form!FieldName2))

.ActiveDocument.Bookmarks("SiteAddress1").Select
.Selection.Text = (CStr(Me.subForm1.Form!FieldName3))


.ActiveDocument.Bookmarks("cboManager").Select
.Selection.Text = (CStr(Me!subForm1.Form!subForm2.Form!FieldName4))

.ActiveDocument.Bookmarks("Contact11stName").Select
.Selection.Text = (CStr(Me!subForm1.Form!subForm2.Form!FieldName5))

.ActiveDocument.Bookmarks("Contact12ndName").Select
.Selection.Text = (CStr(Me!subForm1.Form!subForm2.Form!FieldName6))

.ActiveDocument.Bookmarks("JobNo").Select
.Selection.Text = (CStr(Me!subForm1.Form!subForm2.Form!subForm3.Form!FieldName7))


.ActiveDocument.Bookmarks("DateofComment").Select
.Selection.Text = (CStr(Me!subForm1.Form!subForm2.Form!subForm3.Form!subForm4.Form!FieldName8))


End With

'Print the document in the foreground so Microsoft Word will not close
'until the document finishes printing.
' objWord.ActiveDocument.PrintOut Background:=False

'Close the document without saving changes.
' objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
'
' 'Quit Microsoft Word and release the object variable.
' objWord.Quit
' Set objWord = Nothing
' Exit Sub
 

Users who are viewing this thread

Back
Top Bottom