Requery Subform A from Subform B

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!
 
G

Guest

Paul,

THX for the attempt but no dice. I get an error:
Run-time error '2465':
Application-defined or object-defined error

Here is the code:
Private Sub NumberCompleted_LostFocus()
Me.Parent.SubFrmTotalCompleted.Requery
End Sub

Any other ideas?

Paul Overway said:
Try Me.Parent.SubFrmTotalCompleted.Requery

--
Paul Overway
Logico Solutions
http://www.logico-solutions.com


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.

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!
 
P

Paul Overway

You need to check the actual name of the subform being requeried then. It
should work.

--
Paul Overway
Logico Solutions
http://www.logico-solutions.com


Robert_L_Ross said:
Paul,

THX for the attempt but no dice. I get an error:
Run-time error '2465':
Application-defined or object-defined error

Here is the code:
Private Sub NumberCompleted_LostFocus()
Me.Parent.SubFrmTotalCompleted.Requery
End Sub

Any other ideas?

Paul Overway said:
Try Me.Parent.SubFrmTotalCompleted.Requery

--
Paul Overway
Logico Solutions
http://www.logico-solutions.com


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.

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!
 
G

Guest

Paul,

You were right about the form name, but it still doesn't work.

Now, instead of the error, it does what it did initially. I change the
value from let's say 0 to 5. The LostFocus event should trigger this code:

Private Sub NumberCompleted_LostFocus()
Me.Parent.SubFrmTotalCompleteSubform.Requery
End Sub

That should update the field on the SubFrmTotalCompleteSubform to 5.

The database says 'Calculating...' for like a quarter of a second, but
doesn't update the value in the subform.
I have to move from the current record in SubFrmBatchWorkSubform (the form
I'm in when the LostFocus event triggers the code), then move back and pass
through the field to get it to udpate the SubFrmTotalCompleteSubform fields.

Not sure if it matters, but this is the Record Source for
SubFrmTotalCompleteSubform (the form I am aiming at when using the code tied
to the LostFocus event):
SELECT DISTINCTROW [Q:TotalComplete].[Number Completed] FROM
[Q:TotalComplete];

Even though the subform is based off of a query, shouldn't it requery? Do I
need to insert some kind of save record command before trying to requery?

Paul Overway said:
You need to check the actual name of the subform being requeried then. It
should work.

--
Paul Overway
Logico Solutions
http://www.logico-solutions.com


Robert_L_Ross said:
Paul,

THX for the attempt but no dice. I get an error:
Run-time error '2465':
Application-defined or object-defined error

Here is the code:
Private Sub NumberCompleted_LostFocus()
Me.Parent.SubFrmTotalCompleted.Requery
End Sub

Any other ideas?

Paul Overway said:
Try Me.Parent.SubFrmTotalCompleted.Requery

--
Paul Overway
Logico Solutions
http://www.logico-solutions.com


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!
 
G

Guest

Paul,

THX for taking the time, I am such a tool. I wasn't saving the record, so
when the requery command ran, it was on the last saved value, not what I had
just changed it to.

....It's amazing how you can zone in on what you think is the problem just to
find out it was something dirt-simple that you overlooked thinking it was
'more complicated' than that.

THX for taking the time though, I appreciate it!

Paul Overway said:
You need to check the actual name of the subform being requeried then. It
should work.

--
Paul Overway
Logico Solutions
http://www.logico-solutions.com


Robert_L_Ross said:
Paul,

THX for the attempt but no dice. I get an error:
Run-time error '2465':
Application-defined or object-defined error

Here is the code:
Private Sub NumberCompleted_LostFocus()
Me.Parent.SubFrmTotalCompleted.Requery
End Sub

Any other ideas?

Paul Overway said:
Try Me.Parent.SubFrmTotalCompleted.Requery

--
Paul Overway
Logico Solutions
http://www.logico-solutions.com


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!
 
G

Guest

Robert, You need:

Me.Parent.SubFrmTotalCompleted.Form.Requery

--
sam


Robert_L_Ross said:
Paul,

THX for the attempt but no dice. I get an error:
Run-time error '2465':
Application-defined or object-defined error

Here is the code:
Private Sub NumberCompleted_LostFocus()
Me.Parent.SubFrmTotalCompleted.Requery
End Sub

Any other ideas?

Paul Overway said:
Try Me.Parent.SubFrmTotalCompleted.Requery

--
Paul Overway
Logico Solutions
http://www.logico-solutions.com


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.

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!
 

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