使用按钮

时间:2016-04-09 22:44:49

标签: ms-access

最近开始学习Access,我有点卡在删除表单中的记录。我有一个包含以下代码的列表:

Private Sub lstPickList_AfterUpdate()
Dim rst As DAO.Recordset

Set rst = Me.RecordsetClone
rst.FindFirst "OrderID=" & lstPickList.Column(0) & ""
If rst.NoMatch Then
    MsgBox "The selected record can not be displayed." _
        & "To display this record, you must first turn off record filtering.", _
        vbInformation
Else
    Me.Bookmark = rst.Bookmark
End If
Set rst = Nothing
End Sub

我想用一个按钮来删除列表中当前选择的任何订单。 “DeleteRecord”宏只是给我一个“命令或操作'DeleteRecord'现在不可用。”错误。搜索给了我一堆根本没用的代码。

1 个答案:

答案 0 :(得分:0)

您可以直接从克隆中删除:

If rst.NoMatch Then
    MsgBox "The selected record can not be displayed." _
        & "To display this record, you must first turn off record filtering.", _
        vbInformation
Else
    rst.Delete
End If
相关问题