Updating a subform when another subform is changed

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Sorry for the lousy description in the subject...here goes:

I have an inventory type database set to keep track of material in different
buildings. On a form called Material Detail, I have 2 subforms: frmActivity
(keeps track of additions, subtractions, adjustments, etc) and frmTotals
(displays totals for each location for that material). When I make changes
to the Activity form, I have to switch the main form to another record before
my Totals form will show the new totals. (Hope this makes sense). Is there a
way to update my Totals subform without switching main records?

Thanks in advance.
 
Hi Gina
Either use the set value on change (of the field in subform 1)



Private Sub FieldName_Change()
On Error GoTo FieldName_Change_Err

Forms!Subform1!FieldName = Forms!Subform2!FieldName

FieldName_Change_Exit:
Exit Sub

End Sub



Or (and there are sure to be other ways to do this) create an unbound text
box on the main form, have this filled with the data from the first subform
and then have the 2 nd subform "grab" this data.



Set the ControlSource of the new text box on the main form as
=[Subform1Name].[Form]![FieldName]
(You can always set the visible to No so it can't seen.


Next grab this info by the 2nd subform
Set the cotrol that you want update as
=MainFormName![NewFieldName]

Set this to run On-Change of the new box on the main form.



Hope this helps
 
Thanks for the response, but now looking back on my post I see I wasn't very
clear. What I really want to do is somehow refresh or requery my Totals
subform any time there is a change in the data in any field of the Activity
subform...does this make better sense?

Thanks again and sorry for the unfocused first post.
 
Thank you, thank you, thank you!

Wayne-I-M said:
Hi Gina.

No worries you an use the Me.Requery on most events

Try this (change the field names)


Private Sub FieldName_Change()
On Error GoTo FieldName_Change_Err

Forms!Subform1!FieldName = Forms!Subform2!FieldName

FieldName_Change_Exit:
Exit Sub

Me.Requery

End Sub


Or if you "just" want to requery


Private Sub FieldName_Change()
On Error GoTo FieldName_Change_Err

Me.Requery

End Sub
 
Back
Top