vba MS Access - 使用按钮更改字段值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28215601/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MS Access - Change Field Value with Button
提问by Mus
I have a button which, when clicked, I want to change the value of the Status
field to Closed
.
我有一个按钮,单击该按钮后,我想将该Status
字段的值更改为Closed
.
How can this be achieved?
如何做到这一点?
I have tried Me.status = "Closed"
and a few variations of it but suspect that I am not using the syntax.
我已经尝试过Me.status = "Closed"
它的一些变体,但怀疑我没有使用语法。
UPDATE:
更新:
It is an unbound button (called "Close") within a Single form which has a bound table.
它是具有绑定表的单一表单中的未绑定按钮(称为“关闭”)。
This is what I want to happen:
这就是我想要发生的事情:
- User clicks "Close" button;
- The value within the "Status" field on the active record changes to "Closed"
- 用户点击“关闭”按钮;
- 活动记录上“状态”字段中的值更改为“已关闭”
How can this be achieved?
如何做到这一点?
采纳答案by Mus
I have solved the problem.
我已经解决了这个问题。
This is the VBA code that I wrote which works perfectly for me. Hopefully others may also be able to use it.
这是我编写的 VBA 代码,非常适合我。希望其他人也可以使用它。
Private Sub closeCase_Click()
Me.[Status] = "Closed"
Me.refresh
End Sub