简体   繁体   English

MS-Access 2010:子表单事件 form_load,由 DoCmd.GoToRecord 触发

[英]MS-Access 2010: Subform event, form_load, triggered by DoCmd.GoToRecord

I have a navigation form and a subform that uses the form_load event trigger.我有一个导航表单和一个使用 form_load 事件触发器的子表单。

Private Sub Form_Load()
    DoCmd.GoToRecord , , acNewRec
    CompanyID.SetFocus
End Sub

When it hits "DoCmd.GoToRecord , , acNewRec", it triggers the Form_Load event again and gives a "No Current Record" upon hitting the end.当它点击 "DoCmd.GoToRecord , , acNewRec" 时,它会再次触发 Form_Load 事件并在点击结束时给出 "No Current Record"。 When I press Debug, it highlights "DoCmd.GoToRecord , , acNewRec".当我按 Debug 时,它会突出显示“DoCmd.GoToRecord , , acNewRec”。 I can continue to run the code but then when it hits "CompanyID.SetFocus" I get Run-time Error '2467'.我可以继续运行代码,但是当它点击“CompanyID.SetFocus”时,我得到运行时错误“2467”。 I just want it to open the form, ready to accept a new record.我只是想让它打开表格,准备接受新的记录。

If you don't need to edit existing records on the subform you could set the subform's DataEntry property to True .如果您不需要编辑子表单上的现有记录,您可以将子表单的DataEntry属性设置为True This will hide existing records, essentially starting you off on a new record.这将隐藏现有记录,从根本上让您开始新记录。

http://msdn.microsoft.com/en-us/library/office/aa224193(v=office.11).aspx http://msdn.microsoft.com/en-us/library/office/aa224193(v=office.11​​).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM