我在access里写了个窗体,窗体绑定了数据集,想在窗体上点击按钮,在vba中
Dim rs as new ADODB.Recordset
rs.Open "sql",CurrentProject.Connection, adOpenStatic, adLockOptimistic
rs.MoveFirst
我下面想执行
rs.Update
可是写好后,他老提示我不能更改当前用户打开的数据集,请高手帮忙解决
strSQLEmployees = "SELECT ZP FROM RYJBZL WHERE [SFZH]='" & Me.TextSFZH & "' "
rstEmployees.LockType = adLockBatchOptimistic
rstEmployees.Open strSQLEmployees, CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdText
rstEmployees.MoveFirst
' Store original data
If Not IsNull(rstEmployees!ZP) Then
strOldFirst = rstEmployees!ZP
' Change data in edit buffer
rstEmployees!ZP = Me.Textzp.Value
' Show contents of buffer and get user input
Else
strOldFirst = "Null"
' Change data in edit buffer
rstEmployees!ZP = Me.Textzp.Value
' Show contents of buffer and get user input
End If
rstEmployees.Update
' clean up
rstEmployees.Close
Set rstEmployees = Nothing