Update/requery subform through on close event of another form

brharrii

Registered User.
Local time
Today, 00:59
Joined
May 15, 2012
Messages
272
I am working with 2 forms and a subform.

frmTaskTracker
-subfrmInbox (Datasheet View - based on a query)

frmUpdateInboxItem

subfrmInbox displays a summary of tasks on a task list. The user navigates to frmUpdateInboxItem from frmTaskTracker. After updating a record from frmUpdateInboxItem, it is possible that it the record in question will no longer meet the requirements to have it listed on subfrmInbox.

I have attempted to add code to the on close event of frmUpdateInboxItem to requery the sub form on frmTaskTracker but am not getting the syntax correct.

Could someone help me correct my code? Alternatively is there is a more correct way to do this, I'd be happy to learn it.

Thank you :)

Code:
Option Compare Database
Private Sub cmdClose_Click()
    Me.[frmTasktracker]![subfrmInbox].Requery
    DoCmd.Close acForm, "frmUpdateInboxItem"
 
End Sub
 
Thanks! That web page will be very useful as I continue to learn to work with VBA.

I don't think I quite got what I was going for, but I'm getting closer, would you have another look?

Code:
Option Compare Database
Private Sub cmdClose_Click()
    Forms!frmTasktracker!subfrmInbox.Requery
    DoCmd.Close acForm, "frmUpdateInbox"
 
End Sub

I'm no longer getting an error message, the code seems to run and my secondary form closes, but the requery doesn't seem to happen.

Thanks!
 
Looks okay. This is out of an app I happen to have open:

Forms!frmMap.frmCarsInZone.Requery

I wonder if the record on the form being closed hasn't been saved yet. Try adding this before the requery:

If Me.Dirty Then Me.Dirty = False
 

Users who are viewing this thread

Back
Top Bottom