IngID = Me.listbox_material.Value errors with
IngID = Me.listbox_material.Value = False
从列表框中删除行源
'Check for selection, if none made msgbox
If IsNull(Me.listbox_material) Then
MsgBox "Please make a selection."
Exit Sub
End If
Dim IngID As Long
Dim strSQL As String
'Get selected records ID value
IngID = Me.listbox_material.Value
'SQL statement
strSQL = "DELETE *FROM[LogExpenses] WHERE ID = " & IngID
'Refresh listbox
Me.listbox_material.Requery
当选择一个列表框项目并且我选择“删除按钮”时。应该在表“ LogExpenses”上找到该列表框项目的匹配项,并将其从表中删除。
答案 0 :(得分:0)
更改此:
DELETE *FROM[LogExpenses]
对此:
DELETE FROM [LogExpenses]
看看是否有帮助
答案 1 :(得分:0)
您的代码使用SQL语句定义了字符串值变量strSQL
,但是该代码随后未执行此SQL语句。
因此,我建议将其更改为:
CurrentDb.Execute "DELETE FROM [LogExpenses] WHERE ID = " & IngID
或者:
DoCmd.RunSQL "DELETE FROM [LogExpenses] WHERE ID = " & IngID
答案 2 :(得分:0)
可以请您关注以下内容,然后反馈给我们。
strSQL = "DELETE * FROM [LogExpenses] WHERE ID = '" & IngID & "'"