Requery Subform1 from Subform 2

G

Guest

Ok, here goes.

I have one form (FrmBatchControl) that has two subforms,
SubFrmTotalCompleted and SubFrmBatchWorkSubform.

Note: SubFrmBatchWorkSubform is not a subform of SubFrmTotalCompleted, they
are both subforms of FrmBatchControl.

On the Lost Focus event of a field (NumberCompleted) in the
SubFrmBatchWorkSubform field, I want to requery the SubFrmTotalCompleted
subform. The purpose is that when I add a line of work, I want the subform
listing the total work completed to be requeried to reflect the amount as
soon as I leave the field.

So it's kind of like this:

Main Form
Sub1----------^----------Sub2

I need the proper syntax to requery Sub1 from the LostFocus action of Sub2.

Here is the code I've been working with:
Private Sub NumberCompleted_Change()
Forms![FrmBatchControl]![SubFrmTotalCompleteSubform].Requery

Forms![FrmBatchControl]![SubFrmTotalCompleteSubform]![NumberCompleted].Requery
End Sub

Private Sub NumberCompleted_LostFocus()
Forms![FrmBatchControl]![SubFrmTotalCompleteSubform].Requery

Forms![FrmBatchControl]![SubFrmTotalCompleteSubform]![NumberCompleted].Requery
End Sub

You'll notice it's actually in the OnChange event and the LostFocus event.
When this runs, I see "Calculating..." in the status bar, but nothing happens
to the form. Only when I save the record, move out of the record, back in to
the record and pass through the NumberCompleted field again does the
SubFrmTotalCompleteSubform actually show the new value.

Does anyone have any idea what I'm doing wrong? Is it the syntax, or do I
need to requery the parent form? I'm lost!

THX for reading my rant and if you respond, THX x 10!
 
L

Larry Linson

On the Lost Focus event of a field (Number
Completed) in the SubFrmBatchWorkSubform
field, I want to requery the SubFrmTotalCompleted
subform. The purpose is that when I add a line
of work, I want the subform listing the total work
completed to be requeried to reflect the amount
as soon as I leave the field.

How about Me.Parent!SubFrmTotalCompleted.Requery?

Since this is Access, I think I'd place it in the AfterUpdate event of the
NumberCompleted control in SubFrmBatchWorkSubform.

The Change event fires for every keystroke in the Control, not on completion
of changes to the value. There is a LostFocus event, but that does not mean
that the user completed changes and moved off the Control, just that the
user moved off the Control, perhaps by clicking on another Control without
making any change.

Larry Linson
Microsoft Access MVP


Robert_L_Ross said:
Ok, here goes.

I have one form (FrmBatchControl) that has two subforms,
SubFrmTotalCompleted and SubFrmBatchWorkSubform.

Note: SubFrmBatchWorkSubform is not a subform of SubFrmTotalCompleted, they
are both subforms of FrmBatchControl.


So it's kind of like this:

Main Form
Sub1----------^----------Sub2

I need the proper syntax to requery Sub1 from the LostFocus action of Sub2.

Here is the code I've been working with:
Private Sub NumberCompleted_Change()
Forms![FrmBatchControl]![SubFrmTotalCompleteSubform].Requery

Forms![FrmBatchControl]![SubFrmTotalCompleteSubform]![NumberCompleted].Reque
ry
End Sub

Private Sub NumberCompleted_LostFocus()
Forms![FrmBatchControl]![SubFrmTotalCompleteSubform].Requery

Forms![FrmBatchControl]![SubFrmTotalCompleteSubform]![NumberCompleted].Reque
ry
End Sub

You'll notice it's actually in the OnChange event and the LostFocus event.
When this runs, I see "Calculating..." in the status bar, but nothing happens
to the form. Only when I save the record, move out of the record, back in to
the record and pass through the NumberCompleted field again does the
SubFrmTotalCompleteSubform actually show the new value.

Does anyone have any idea what I'm doing wrong? Is it the syntax, or do I
need to requery the parent form? I'm lost!

THX for reading my rant and if you respond, THX x 10!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top