我有一个公式a_form
,它有一个数据绑定到我的表my_table
。
如果用户点击了某个按钮,我想将我的字段txt_mytext
从"Hello"
更新为"Hello World!"
如何在不发生写入冲突的情况下更新此字段:
This record has been changed by another user since you started editing it. If you save the record, you will overwrite the changes the other user made. Copying the changed to the clipboard will let you look at the values the other user entered, and then paste your changes back in if you decide to make changes.
我尝试了以下方法:
a_form!txt_mytext = "Hello World!"
。我不清楚为什么我会使用这种方法得到写入混淆。是否有第三种方法或是否必须致电Me!Requery
,Me!Refresh
,Me!Dirty
...以避免写入冲突?
frm_a_form
中的代码是:
Private Sub btn_calculate_Click()
Forms!a_form!txt_mytext = "Hello World!"
End Sub
答案 0 :(得分:1)
我不明白为什么你会发生写冲突。但是,在您自己的回答中,您报告了此作品:
Forms!a_form!txt_mytext = "Hello World!"
由于这种方法有效,请从该表单上的命令按钮的click事件中执行相同的操作:
Private Sub btn_calculate_Click()
Me!txt_mytext = "Hello World!"
End Sub
如果要立即保存该更改,请将其添加到单击事件过程:
Me.Dirty = False
答案 1 :(得分:0)
这似乎有效:
Forms!a_form!txt_mytext = "Hello World!"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
我通过googeling around http://www.tek-tips.com/viewthread.cfm?qid=446217
随机发现了这一点请随意解释此解决方案或添加您自己的答案。