Help with DoCmd...

Lissa

Registered User.
Local time
Today, 00:07
Joined
Apr 27, 2007
Messages
114
If I have the following code in an After Update Event in a field on a subform... this will refresh the subform with current focus as I expect...

Private Sub LaborCategory1_Hrs_AfterUpdate()
DoCmd.RunCommand acCmdRefresh
End Sub

...but what if I want to do the same thing - refresh a subform but instead of refreshing the subform under current focus... I would like to refresh a second subform. So if a user changes the field LaborCategory1_Hrs, after it's updated I would like it to trigger an automatic refresh of another subform. I'm not sure how to approach this. I sure would appreciate any ideas.

Thanks,
Lissa
 
Me.Refresh will refresh the current form as well, but is much more " flexible "

I.e.
Me.Parent.Refresh will refresh the parent form of the one selected and
Me.SubformName.Form.Refresh will refresh your subsform.

Depening on your setup a combination of above will work or either example

Good luck !
 
Thanks for your reply namliam. I'm still not having any luck.

I've tried the following variations of code in the after update event of the field that should trigger an update to the second subform. The field is on a subform called 'subfrmWBS' and I want it to trigger a refresh of the field txtLabHrs1 on the subform called subfrmPROPOSALSetup.... I would like it to either refresh the field or the entire subform. (Both subforms are on a main form called frmPROPOSALSetup).

Private Sub LaborCategory1_Hrs_AfterUpdate()
'Forms.frmPROPOSALSetup.subfrmPROPOSALSetup.Form.Requery
'DoCmd.Requery (Me.subfrmPROPOSALSetup.Form.txtLabHrs1)
'Forms!frmPROPOSALSetup.Requery
Forms.frmPROPOSALSetup.subfrmPROPOSALSetup.Form.Refresh


End Sub
 
Forms.frmPROPOSALSetup.subfrmPROPOSALSetup.Form.Re fresh

You have taken that space out I guess?!
 
Lissa,

I would put in under event lost focus for LaborCategory1_Hrs
me.<namesubform>.requery (assuming the subform is part of the same form as LaborCategory1_Hrs.
 
Me.Parent.subfrmPROPOSALSetup.requery

That should do the trick I think.
 
Forms.frmPROPOSALSetup.subfrmPROPOSALSetup.Form.Re fresh

You have taken that space out I guess?!

For some reason when I cut/paste the code to post it - it always puts that extra space in...
 
Doin' the Happy Dance!!

Thanks for your input namliam, matt and janz!!

From a previous post by georgedwilkinson I was able to find an alternate solution that works just as well.... all my subforms were on a tabbed control. I kept focusing on adding the code to the after update event of a single field on a subform hoping I could trigger an update on another subform. georgedwilkinson suggested putting a refresh command in the on change event of the tabbed control. So if the user made a change to the field and I have to click back to another page of the tabbed form to see the update... that on change event catches the change made to the field so it works like I want it to! :)
Also, I added a refresh command to the field at the lost focus event like janz suggested and I can see the updated summary even faster!

I'm one happy camper now :)
 

Users who are viewing this thread

Back
Top Bottom