So I currently have a database for my science students to record their examination notes.
On the 'examination' form the students fill out their case and item number and the lab room number. These all are static fields.... But then I have a related table that stores the students names... So I built a subform in to the main form where the students can record their names as well as their partners names using their initials, ABC (for example). Most of the time they work in partners but sometimes they are in groups of 3 and rarely in groups of 4.
Now I have a separate Word template document where the students need to add their photos of the examination (I don't want photos stored in my Access database). I get the students to press a button and it runs the following VBA code;
Code:
Private Sub cmd_contrecrdv2_Click()
Me.Refresh
Dim appWord As Word.Application
Dim DOC As Word.Document
'Avoid error 429, when Word isn’t open.
On Error Resume Next
Err.Clear
'Set appWord object variable to running instance of Word.
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
'If Word isn’t open, create a new instance of Word.
Set appWord = New Word.Application
End If
Set DOC = appWord.Documents.Open(C:\Users\TeacherJDS\Examinations\2. Templates\Imaging Record.docx", , True)
With DOC
.Bookmarks("date").Range.Text = Me![Dateofexamination]
.Bookmarks("CaseNo").Range.Text = Me![FSDCaseNum]
.Visible = True
.Activate
End With
Set DOC = Nothing
Set appWord = Nothing
Exit Sub
End Sub
Here is a screenshot of the an example of the Word document....
The code works beautifully - BUT I can't send the subform data (that contains a list of the student names and their partners) to a bookmark in Word??? Does anyone know how to do this? I would like it to be in a table straight underneath the header on that Word document... And it would look like...
Examined by:
ABC
XYZ
CRS
Then the students would add their photos and any other drawings.
Any help would be much appreciated