On Error GoTo ErrorHandler
Dim strTemplate As String
Dim strFileName As String
Dim objApp As Object 'New Word.Application
Dim objDoc As Object 'Word.Document
Dim objField As Object 'Word.Field
Dim rst As Object
Dim blnNoQuit As Boolean
strTemplate = CurrentProject.Path &"\模板\通知单模板.doc"
'设置鼠标指针为沙漏形状
DoCmd.Hourglass True
Set objApp = CreateObject("Word.Application")
Set objDoc = objApp.Documents.Open(strTemplate)
Set rst = CurrentDb.OpenRecordset("SELECT * FROM tbl通知单 WHERE ID=" &ID, , 4)
If Not rst.EOF Then
+7Votes
This is a string connector, indicating that the ID is a variable, such as ID=1234
then the SQL is
SELECT * FROM tblNotice WHERE ID=1234
and 4 of them open the recordset as read-only.