Private Sub Form_Current()
Dim rst As Object
On Error GoTo RecLab_Error: '添加这个句为了避免新增记录时候的系统报错
Set rst = Me.RecordsetClone
rst.Bookmark = Me.Bookmark
If Me.RecLab.ForeColor <> vbBlack Then Me.RecLab.ForeColor = vbBlack
Me.RecLab.Caption = rst.AbsolutePosition + 1 & "/" & rst.RecordCount
If Me.RecordsetType <> 2 Then Me.RecordsetType = 2 '原有记录在未单击修改按钮之前皆为记录锁定状态
Exit Sub
RecLab_Error:
If Me.RecLab.ForeColor <> vbRed Then Me.RecLab.ForeColor = vbRed
Me.RecLab.Caption = "新增记录"
Me.RecordsetType = 0 ' 解除记录锁定状态
End Sub
不过现在有个问题,怎么避免在刚打开窗体的时候rst的recordcount值为1?是不是必须将记录移动到最后才能得到正确的recordcount?