检测记录此外,并获得自动编号ID的新记录 [英] Detecting record addition, and obtaining Autonumber ID for new Record

查看:165
本文介绍了检测记录此外,并获得自动编号ID的新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题相关,我怎样检测一个形式的用户正在添加记录?这将是理想的,如果我知道这个尽快形式的当前记录变成了新(导航超越过去的现有记录,或单击新建导航按钮),但只要第一块数据开始了解要输入的将是几乎一样好。我猜测,这将是测试的在form_Current东西的,但什么(或者是有更好的方法)?

Related to this question, how do I detect that a form user is adding a record? It would be ideal if I knew this as soon as the form's "current record" became "new" (navigating beyond the last existing record, or clicking the "new" navigation button), but knowing as soon as the first piece of data begins to be entered would be almost as good. I'm guessing that this would be testing something in form_Current, but what (or is there a better way)?

另外有关,最早什么是我能找到的(自动编号)的ID为新纪录?这需要保存,不是吗?难道它会自动填充到窗体的记录(我知道这是的没有的为code驱动的情况下保存(.AddNew ... .Update))?我问这样做的原因是开始填充子表子窗体的后面(该数据是这样的,我可以自动创建一个默认的数据集,用户可以确认或修改)。

Further related, what is the earliest that I can find the (Autonumber) ID for the new record? That requires a save, does it not? Is it automatically populated into the form's recordset (I know this is not the case for code-driven saves (.AddNew ... .Update))? The reason I'm asking for this is to begin populating the child table behind the subform (the data is such that I can auto-create a "default" data set that the user can confirm or modify).

推荐答案

我想你想要的:

Private Sub Form_Current()
    If Me.NewRecord Then

End Sub

自动编号不应该与子表中使用到的记录已被保存,否则你会(应该)遇到完整性问题。当子窗体获得焦点,主表的自动编号将被保存。不要忘记,你可以做很多与link子,链接子窗体的主领域。

The autonumber should not be used with a child table until the record has been saved, or you will (should) run into integrity problems. When the subform gets focus, the autonumber of the main table will have been saved. Do not forget that you can do a lot with link child, link master fields on a subform.

这篇关于检测记录此外,并获得自动编号ID的新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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