我希望在用户单击删除按钮时执行以下Delete语句。
CurrentDb.Execute "Delete from [TableName] where ColumnName is not null"
但我希望用户输入tablename和columnName。你能帮忙吗
答案 0 :(得分:0)
这将从表单控件中获取参数:
SELECT *
FROM Customers
WHERE Country = _
[Forms]![frmSelectCountry]![txtCountry]
这将提示用户“输入县”:
SELECT *
FROM Customers
WHERE Country = _
[Enter Country]
要提示用户输入表名并提示用户“输入县”:
tblName= InputBox("Please enter a name for the source table", "?")
mysql = "DELETE * FROM " & tblName _
& "WHERE (((" & tblName & ".[City])=[Enter City]));"
您可以使用组合框控件(名为“cboTable”)构建一个表单(名为“frmSelectTable”),其中列出了可供选择的表,并让代码检索组合框控件的值。
tblName = [Forms]![frmSelectTable]![cboTable]
与您的作品合并:
tblName = InputBox("Please enter a name for the source table", "?")
mysql = "DELETE * FROM " & tblName _
& "WHERE ColumnName Is Not Null;"
CurrentDb.Execute mysql
这是一个教程,它将引导您制作一个包含列出数据库中所有表的组合框的表单: How to Get all Table Names into Combo box