Private Sub PrintAL_Click() On Error GoTo PrintAL_Err ' Open a document in Word and insert text Dim rstStudent As New ADODB.Recordset Dim appWord As New Word.Application Dim AcLtrPath As String Dim WordDoc As String Me.ALDate.Value = Now() Me.AcceptanceLetterSent.Value = True [AccLtrPath] = "S:\CMS\TEMPLATE\" If Me.CourseID.Column(4) = 1 Then [WordDoc] = AccLtrPath & "accept.dot" ' standard UK letter If Me.CourseID.Column(4) = 2 Then [WordDoc] = AccLtrPath & "acceptth.dot" ' Thailand If Me.CourseID.Column(4) = 3 Then [WordDoc] = AccLtrPath & "acceptst.dot" ' summer programme and If Me.CourseID.Column(4) = 4 Then [WordDoc] = AccLtrPath & "acceptst.dot" ' Study tour If Me.CourseID.Column(4) = "" Or Me.CourseID.Column(4) = 0 Then MsgBox "It looks like you haven't selected the kind of course." _ & vbCrLf & vbCrLf & "Try going back to the Course database and select something like UK Course or something like that.", vbInformation, "Nothing to worry about" End If ' Open a recordset based on the qStudentAcceptLetter query. rstStudent.Open " qStudentAcceptLetter ", _ CurrentProject.Connection, adOpenKeyset, adLockOptimistic ' Open a Word document based on the template, turn off spell check, ' Move to the bookmarks in the document then display Word Do Until rstStudent.EOF With appWord .Documents.Add WordDoc .ActiveDocument.ShowSpellingErrors = False .Visible = True End With ' Loop through the recordset returned by the query inserting the student details appWord.Selection.Goto wdGoToBookmark, Name:="Title" appWord.Selection.TypeText rstStudent!Title appWord.Selection.Goto wdGoToBookmark, Name:="FName" appWord.Selection.TypeText rstStudent!FName appWord.Selection.Goto wdGoToBookmark, Name:="LastName" appWord.Selection.TypeText rstStudent!LastName appWord.Selection.Goto wdGoToBookmark, Name:="FaxNo" appWord.Selection.TypeText rstStudent!FaxNo appWord.Selection.Goto wdGoToBookmark, Name:="Title2" appWord.Selection.TypeText rstStudent!Title appWord.Selection.Goto wdGoToBookmark, Name:="LName2" appWord.Selection.TypeText rstStudent!LName appWord.Selection.Goto wdGoToBookmark, Name:="Course" appWord.Selection.TypeText rstStudent!CourseName appWord.Selection.Goto wdGoToBookmark, Name:="Short" appWord.Selection.TypeText rstStudent!ShortProgrammeName appWord.Selection.Goto wdGoToBookmark, Name:="Title3" appWord.Selection.TypeText rstStudent!Title appWord.Selection.Goto wdGoToBookmark, Name:="FName2" appWord.Selection.TypeText rstStudent!FName appWord.Selection.Goto wdGoToBookmark, Name:="LName3" appWord.Selection.TypeText rstStudent!LName appWord.Selection.Goto wdGoToBookmark, Name:="Title4" appWord.Selection.TypeText rstStudent!Title appWord.Selection.Goto wdGoToBookmark, Name:="LName4" appWord.Selection.TypeText rstStudent!LName appWord.Selection.Goto wdGoToBookmark, Name:="Prog" appWord.Selection.TypeText rstStudent!ProgrammeName appWord.Selection.Goto wdGoToBookmark, Name:="Prog2" appWord.Selection.TypeText rstStudent!ProgrammeName appWord.Selection.Goto wdGoToBookmark, Name:="Course2" appWord.Selection.TypeText rstStudent!CourseName appWord.Selection.Goto wdGoToBookmark, Name:="Start" appWord.Selection.TypeText rstStudent!StartDate appWord.Selection.Goto wdGoToBookmark, Name:="End" appWord.Selection.TypeText rstStudent!EndDate appWord.Selection.Goto wdGoToBookmark, Name:="Fee" appWord.Selection.TypeText rstStudent!CourseFee rstStudent.MoveNext Loop Exit Sub PrintAL_Err: MsgBox Err & " " & Err.Description End Sub