i have created this code within one of my forms as a command button. i aleady created a word document with bookmarks called FACULTY.doc and when the button is pressed the data which is in the active form are exported to the word document but the data from the field Housename doesn't get exported since its not a field in the active form but a field in a related table.
So does anyone know how to get the data from a field in a related table to be export to a word document within a form which doesn't contain that field?
Here's the code:
Private Sub Command36_Click()
Dim wdApp As Word.Application, wdDoc As Word.Document
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set wdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
wdApp.Visible = True
Set wdDoc = wdApp.Documents.Open("C:\Users\Alex\Desktop\FACULTY.doc")
With wdApp.ActiveDocument.Bookmarks
.Item("Firstnamebm").Range.Text = [Firstname]
.Item("Surnamebm").Range.Text = [Surname]
.Item("Housenamebm").Range.Text = [Housename]
End With
End Sub
So does anyone know how to get the data from a field in a related table to be export to a word document within a form which doesn't contain that field?
Here's the code:
Private Sub Command36_Click()
Dim wdApp As Word.Application, wdDoc As Word.Document
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set wdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
wdApp.Visible = True
Set wdDoc = wdApp.Documents.Open("C:\Users\Alex\Desktop\FACULTY.doc")
With wdApp.ActiveDocument.Bookmarks
.Item("Firstnamebm").Range.Text = [Firstname]
.Item("Surnamebm").Range.Text = [Surname]
.Item("Housenamebm").Range.Text = [Housename]
End With
End Sub