简体   繁体   English

Access 2007:从子表单的数据表视图刷新父表单

[英]Access 2007: Refresh Parent Form from datasheet view in subform

I have a parent form named frmProject. 我有一个名为frmProject的父表单。 There is a Total Time text box called txtTotalTime - the data control source does a DLookUp for a query that adds together time spent. 有一个称为txtTotalTime的“总时间”文本框-数据控件源对查询执行DLookUp,以将花费的时间加在一起。

The subform on the Project Form is called frmProjectHistory. 项目窗体上的子窗体称为frmProjectHistory。 The default view of it is datasheet view. 它的默认视图是数据表视图。

I've tried setting the On Dirty event for frmProjectHistory to Me![frmProject].requery or Me![frmProject].[txtTotalTime].requery (or Forms! inplace of Me!). 我尝试将frmProjectHistory的On Dirty事件设置为Me![frmProject] .requery或Me![frmProject]。[txtTotalTime] .requery(或Forms!代替Me!)。 each time I get "can't find the object" followed by the Me!frmProject.... 每次我收到“找不到对象”之后都出现Me!frmProject。

I'm needing to update the Total Time box on frmProject every time either a new record is entered in the subform datasheet view - or when time is adjusted for a previous event. 每当在子窗体数据表视图中输入新记录时,或者为上一个事件调整时间时,我都需要更新frmProject上的Total Time框。

Don't you need to requery all the data on the Parent form? 您不需要重新查询“父”表单上的所有数据吗? If so, you just use: 如果是这样,您只需使用:

Me.Parent.Requery

If you want to only refresh that one text box, then try different variations of: 如果您只想刷新一个文本框,请尝试以下不同的变体:

Me.Parent.txtTotalTime.Requery

or 要么

Me.Parent.Form.txtTotalTime.Requery

Since frmProjectHistory is the child form you can't reference the parent with the Me keyword. 由于frmProjectHistory是子窗体,因此无法使用Me关键字引用父窗体。 Write out the whole reference - Forms.frmProject.txtTotalTime.Requery in VBA or =[Forms]![frmProject]![txtTotalTime].Requery from the properties window. 写出整个参考Forms.frmProject.txtTotalTime.Requery中的Forms.frmProject.txtTotalTime.Requery或从属性窗口=[Forms]![frmProject]![txtTotalTime].Requery

Also, I think you should use AfterUpdate event. 另外,我认为您应该使用AfterUpdate事件。 I believe the OnDirty fires before the changes are actually saved. 我相信在实际保存更改之前会触发OnDirty

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

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