|
Question : Requery Subform Occurs 3 times
|
|
Hello
I have a bound form (frmAsset) and an Unbound Subform (subfrmProfitLoss). To refresh the contents of the subform, I have included this within the On Current event of the main form:
Me.subfrmProfitLoss.Requery
This does the job that I want, however, the requery occurs 3 times so takes too long. The subform searches through a recordset and performs some calculations within the Subform's On Current event.
Can someone let me know how to stop the code within the subform running 3 times?
Thanks
|
|
Answer : Requery Subform Occurs 3 times
|
|
As you have now established, you cannot requery something that has no recordsource.
But based on your last post, surely all you want to do is run on-demand the procedure that does the calculations.
So you need to move the code from the current event procedure into a new separate procedure and run this procedure when you move to a new mainform record or when you click a button or whatever. The best place for this code, in my view, is in the main form module, not the subform module. This means that all references to the subform controls will have to be fully qualified : FORMS!mainformnamehere!nameofsubformcontrolonmainformhere.FORM!controlnameonsubformhere
But this gets you out of the situation where you are reliant on a subform event which may run once, twice or not t all in different situations.
Pete
|
|
|
|