将新记录保存到表中 [英] Save new record to table

查看:66
本文介绍了将新记录保存到表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我写了这段代码来保存记录而不关闭表格

所以不要把代码写成

docmd.close,acform" fdlgNewAccount" ,,, acSaveYes


I''ve written this code to save the record without closing the form
so instead of write the code as
docmd.close, acform "fdlgNewAccount",,,acSaveYes

展开 | 选择 | Wrap | 行号

推荐答案

DoCmd。保存是保存FORM,而不是记录。


我没有测试这个,但Access MVP在其他地方说:


如果你真的需要这样做,你可以写


RunCommand acCmdSaveRecord





如果Me.Dirty然后Me.Dirty = False
The DoCmd.Save is saving the FORM, not the record.

I didn''t test this, but an Access MVP said elsewhere:

If you really need to do this, you can write

RunCommand acCmdSaveRecord

or

If Me.Dirty Then Me.Dirty = False




实际上我能够将记录保存到表中就好了。只是当我的用户使用数据库时,有时,在他们将所有数据输入表单后,单击确定按钮,然后什么都不会发生。但有时他们能够毫无问题地添加。


这是我的完整代码。
Hi,
Actually I was able to save record into the table just fine. It''s just that when my users use the database, sometime, after they have entered all data into the form, click on OK button, then nothing happen. But sometimes they were able to add without any problem.

Here is my complete code.
展开 | 选择 | Wrap | 行号


我不是很确定你的意思。当你拿出DoCmd.Close acForm,frmPatient",acSaveNo"?

时,会出现什么问题。另外如果MsgBox(strMsg,vbInformation + vbOKOnly,Record Added!) )= vbOK然后因为没有其他选择,所以没有意义。你可以摆脱If。
I''m not quite sure what you mean. What goes wrong when you take out the "DoCmd.Close acForm, "frmPatient", acSaveNo"?
Also "If MsgBox(strMsg, vbInformation + vbOKOnly, "Record Added!") = vbOK Then" doesn''t really make sense, since there are no other options. You can get rid of the If.


这篇关于将新记录保存到表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆