我希望在更改条目之前获取cmb值,方法是使用" .oldValue"。正确分配了值(根据调试器),但运行SQL Access要求手动输入。手动输入工作正常,所以剩下的代码应该没问题。
我的代码:
Dim CategoryNameBeforeChange As String
CategoryNameBeforeChange = Forms!frmCategory!txtCategoryName.OldValue
SQL = "UPDATE CategoryTbl " & _
"SET CategoryTbl.CategoryName = Forms!frmCategory!txtCategoryName " & _
"WHERE (CategoryTbl.CategoryName = CategoryNameBeforeChange);"
知道这里出了什么问题吗?
非常感谢任何帮助!
答案 0 :(得分:0)
试试这个:
SQL = "UPDATE CategoryTbl " & _
"SET CategoryTbl.CategoryName = Forms!frmCategory!txtCategoryName " & _
"WHERE (CategoryTbl.CategoryName = " & CategoryNameBeforeChange & ");"
我怀疑CategoryName是文本,在这种情况下它应该是
SQL = "UPDATE CategoryTbl " & _
"SET CategoryTbl.CategoryName = Forms!frmCategory!txtCategoryName " & _
"WHERE (CategoryTbl.CategoryName = '" & CategoryNameBeforeChange & "');"