ms acess记录集填充表单

时间:2017-07-11 17:12:02

标签: access-vba

我正在尝试使用查询中的记录填充表单。使用此代码,它仅填充最后一条记录。该查询加入了许多表,并且不可更新。 (我遗漏了查询,因为它很长而不是问题)我想将记录加载到表单中并允许用户更新。

Private Sub Form_Load()
Dim strSQL As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim siteno As String
Set dbs = CurrentDb

strsql = "query that works"
Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)
siteno = "ABCD"

With rst
    Do While Not rst.EOF
        On Error Resume Next 
        Me.SITE_NO = rst.Fields("SITE_NO")
        rst.MoveNext
    Loop
End With

Set rst = Nothing
Set dbs= Nothing
End Sub

0 个答案:

没有答案