简体   繁体   中英

Access 2007: Refresh Parent Form from datasheet view in subform

I have a parent form named 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.

The subform on the Project Form is called 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!). each time I get "can't find the object" followed by the 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.

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. Write out the whole reference - Forms.frmProject.txtTotalTime.Requery in VBA or =[Forms]![frmProject]![txtTotalTime].Requery from the properties window.

Also, I think you should use AfterUpdate event. I believe the OnDirty fires before the changes are actually saved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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