1
votes

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.

2

2 Answers

0
votes

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.

1
votes

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