Requerying Subforms

PaulJK

Registered User.
Local time
Today, 07:07
Joined
Jul 4, 2002
Messages
60
Hi,

I have searched various solutions from this forum, but am still not getting the result I am after.

I have a form detailing sales (frmSales). Within this form there are two subforms (subfrmSalesItemsForSubfrm) and (frmsubfrmCalcCommSunnByClient). The first offers options to select products sold. The second calculates a total amount sold excluding certain products.

What I would like to happen is once subfrmSalesItemsForSubfrm is updated, frmsubfrmCalcCommSunnByClient is updated to to reflect a new total.

I understand I should be using requry rather than refresh. I have tried this on AfterUpdate on subfrmSalesItemsForSubfrm and in various other place on the main form and the subforms.

All fields in frmsubfrmCalcCommSunnByClient are locked and the user cannot access these.

The code I have been using has been:

Me.Form![frmSales]![frmsubfrmCalcCommSunnByClient].Requery

or

Me.frmsubfrmCalcCommSunnByClient.Requery

If someone can provide some guidance on where I am going wrong, it would be appreciated.
 
Syntax:
Form![frmSales]![frmsubfrmCalcCommSunnByClient].Requery
or
Me.Parent!frmsubfrmCalcCommSunnByClient.Requery

The first syntax you tried is incorrect because you are specifying the complete path to the object you want to requery. Me is not used with this syntax. IN the second attempt, you are using Me. correctly except that the subform you are referencing is not part of the form your code is running in. Me. is only used to reference fields or controls of the current form from within that form's class module.
 
Thanks pat for your reply. Where would you suggest I place this code. I have tried on OnCurrent, AfterUpdate, OnFocus etc on the main form frmSales and on each of the subforms but frmsubfrmCalcCommSunnByClient is not updating once subfrmSalesItemsForSubfrm is updated.

Thanks
 
You need to put it in the AfterUpdate event of the subform that is changing. So if subA changes, you need to requery subB from the AfterUpdate event in subA.
 

Users who are viewing this thread

Back
Top Bottom