Hi im trying to get access to print out email addresses in a word document using a recordset but while the document is opening nothing is printing out. Is there something wrong with my syntax? Any help please, here's my code:
retiring = InputBox("Enter the Code of the Tutor Retiring", "Retiring Tutor")
Set rs = db.OpenRecordset("Select [STU_EMAIL] from [tblStudents] where tblStudents.[STU_TU_CODE] = " & "'" & retiring & "';")
TheAddress = rs![STU_EMAIL]
rs.MoveFirst
Do While Not rs.EOF
With WordObj.ActiveDocument.Bookmarks
ActiveDocument.Bookmarks("bmk1").Range.Text = TheAddress
End With
rs.MoveNext
Loop
retiring = InputBox("Enter the Code of the Tutor Retiring", "Retiring Tutor")
Set rs = db.OpenRecordset("Select [STU_EMAIL] from [tblStudents] where tblStudents.[STU_TU_CODE] = " & "'" & retiring & "';")
TheAddress = rs![STU_EMAIL]
rs.MoveFirst
Do While Not rs.EOF
With WordObj.ActiveDocument.Bookmarks
ActiveDocument.Bookmarks("bmk1").Range.Text = TheAddress
End With
rs.MoveNext
Loop