Correctly assigned parameter valuecan not be used

我只是一个虾纸丫 提交于 2019-12-11 17:50:50

问题


I want to get a cmb-value before the entry is changed, by using ".oldValue". The value is correctly assigned (according to debugger), but running the SQL Access is asking for a manual entry. Doing the entry manually works fine, so the remaining code should be fine.

My Code:

Dim CategoryNameBeforeChange As String

CategoryNameBeforeChange = Forms!frmCategory!txtCategoryName.OldValue

SQL = "UPDATE CategoryTbl " & _
"SET CategoryTbl.CategoryName = Forms!frmCategory!txtCategoryName " & _
"WHERE (CategoryTbl.CategoryName = CategoryNameBeforeChange);"

Any idea what went wrong here?

Any help is greatly appreciated!


回答1:


Try this:

SQL = "UPDATE CategoryTbl " & _
"SET CategoryTbl.CategoryName = Forms!frmCategory!txtCategoryName " & _
"WHERE (CategoryTbl.CategoryName = " & CategoryNameBeforeChange & ");"

I suspect that CategoryName is text, in this case it should be

SQL = "UPDATE CategoryTbl " & _
"SET CategoryTbl.CategoryName = Forms!frmCategory!txtCategoryName " & _
"WHERE (CategoryTbl.CategoryName = '" & CategoryNameBeforeChange & "');"


来源:https://stackoverflow.com/questions/48949153/correctly-assigned-parameter-valuecan-not-be-used

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!