I have made a query in access that takes the value of a list box and on that value, it shows the appropriate results.
This value is a course ID, (as in a college course). I want to be able to send a letter to everyone on a specific course, using the same word template with the students name, adress and course etc. Leaving me a blank letter to fill in the text.
I have created a combo box that displays the list of courses and have put the value [forms]![gen_letter]![cmbcourse].[value] under the course ID in the query.
In other cases, when the course is selected and the query is run the results are filtered to just the course I selected in my combo box.
However, when I merge out to word with this method, a box comes up when word opens asking the value of "[forms]![gen_letter]![cmbcourse].[value]", if I type in the course ID it does filter, but I don't want this to happen. I want it to pick up the information from the combo box as it always does within access.
I am assuming this happens because Access is no longer in the foreground; word is. Is there any way to get it to run the query and pick up the information from the combo box.
The code I am using for the "submit" button on my form is as follows:
Any help is much appreciated, thanks.
This value is a course ID, (as in a college course). I want to be able to send a letter to everyone on a specific course, using the same word template with the students name, adress and course etc. Leaving me a blank letter to fill in the text.
I have created a combo box that displays the list of courses and have put the value [forms]![gen_letter]![cmbcourse].[value] under the course ID in the query.
In other cases, when the course is selected and the query is run the results are filtered to just the course I selected in my combo box.
However, when I merge out to word with this method, a box comes up when word opens asking the value of "[forms]![gen_letter]![cmbcourse].[value]", if I type in the course ID it does filter, but I don't want this to happen. I want it to pick up the information from the combo box as it always does within access.
I am assuming this happens because Access is no longer in the foreground; word is. Is there any way to get it to run the query and pick up the information from the combo box.
The code I am using for the "submit" button on my form is as follows:
Private Sub cmdletter_Click()
Dim oApp As Object
Dim pos As Integer
Dim filename As String
pos = InStrRev(CurrentDb.Name, "\")
filename = Left(CurrentDb.Name, pos) & "QSUER Documents\Generic Letter.doc"
Set oApp = CreateObject("word.application")
oApp.Visible = True
Set objword = CreateObject("word.basic")
objword.fileopen filename
End Sub
Any help is much appreciated, thanks.