Export from FormA, then FormB?

Steven811

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

I have the code and it works to export data from an active form to Word. The Form also has 2 subforms and I don't know what code I should be using to move from the end of one form to the next and then perform the same procedure.

The code that I am using successfully is the Microsoft example and is enclosed for info.

I would be grateful for some assistance.

Steven811

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("DateofComment").Select
.Selection.Text = (CStr(Forms!forProject!DateofComment))

.ActiveDocument.Bookmarks("Comments").Select
.Selection.Text = (CStr(Forms!forProject!Comments))

.ActiveDocument.Bookmarks("Action").Select
.Selection.Text = (CStr(Forms!forProject!Action))

.ActiveDocument.Bookmarks("ActionByDate").Select
.Selection.Text = (CStr(Forms!forProject!ActionByDate))

.ActiveDocument.Bookmarks("ByWhom").Select
.Selection.Text = (CStr(Forms!forProject!ByWhom))



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

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

Exit Sub
End Sub
 
Export from FormA, then FormB

Steven811
Are the 2 subforms all on WORD with the main form as 1 document?
Is the information the same on the 2 subforms as the main form or all different?
Rae
 
Last edited:
Export

Hi

I'm sorry I don't quite understand the question, I'm having another dim day.

The forms are in Access 2k.

The cmdbutton takes the active forms recordset and sends it to Word and stops there. I need it to got the nested subform1 and take that data and then finally to nested subform2.

This data is then pasted through bookmarks into a single Word document.

This problem is driving me nuts and any assistance would be appreciated.

Thanks

Steven811
 
Export

Steven811
Sorry it was me not reading your post properly.
I have not tried it but would have thought you need to specify the text from the subform i.e. .ActiveDocument.Bookmarks("Action").Select
.Selection.Text = (CStr(Forms!forProject!forprojectSubform!Action))
Rae
 

Users who are viewing this thread

Back
Top Bottom