访问VBA:写入所选记录

问题描述 投票:0回答:1

表单每次显示一条记录。我想,通过单击按钮,系统会在所选记录的行中的数据库表上放置一个值。就像是:

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand write "example" in the field <FieldName> of the selected record

有可能是这样的吗?

access-vba
1个回答
0
投票

最简单的方法是将字段绑定到文本框,然后将文本框的Visible属性设置为False。

现在,在OnClick事件中调用此代码:

Me!NameOfTextbox.Value = "example"
' Save the record.
Me.Dirty = False
© www.soinside.com 2019 - 2024. All rights reserved.