我继续得到“运行时错误'424':需要对象”,我不知道为什么,当我按下调试时,它会将我带到行qdf.SQL = strSQL
并突出显示为黄色。我想知道是否有人知道这是什么问题?
Sub UpdateX()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb
Set rs = db.OpenRecordset("References")
strSQL = "SELECT References.DocNum, References.Availability " & _
"FROM References " & _
"WHERE References.Source = 'Book' " & _
"ORDER BY References.DocNum;"
qdf.SQL = strSQL
DoCmd.OpenQuery "qryTest"
End Sub
由于
答案 0 :(得分:1)
qdf
是Nothong
(null)。您需要将qdf
设置为某个内容。
答案 1 :(得分:0)
试试这个
strSQL = "SELECT References.DocNum, References.Availability FROM References WHERE References.Source = 'Book' ORDER BY References.DocNum;"
Set rs = CurrentDb.OpenRecordset(strSQL)
Do until rs.EOF
' str2 =基于rs更新查询
DoCmd.RunSQL STR2
rs.MoveNext
Loop
rs.Close