trouble updateing Main form from subform after Me.Recalc

  • Thread starter Thread starter Philip
  • Start date Start date
P

Philip

Hello All
Have a simple problem with a subform.
I have a form called Order, and a subform called OrderItems_Subform. The
Subform is a continous form.
Simple enough.
when items (records) are added to the Subform, a field in the footer of the
subform is recalculated with me.recalc
The field in the footer part of the subform is
TotalPrice.Recordsource=Sum([Price]).
This works great.
However, I need to transfer that value to the Orders form. I need to do
this as soon as the recalc is done. (dynamic update for the user).
In the subform I have the following code on Price_AfterUpdate()

Me.Recalc
Forms!Order!TotalPrice = Me!TotalPrice

Problem is, the recalc updates the Me!TotalPrice in the subform no problem,
but the next line does not update the TotalPrice field in the Order form.
Why?

Strange thing is, if I put a break point in at me.recalc, then step through,
it updated the TotalPrice in the Order form OK.
???
What have I got to do between these two lines to make it work? The stepping
through is allowing enough time (or something) to happen, but just running
it isnt.

Help!

Thanks... Philip Middleton
 
Philip

I have tried to reproduce your problem on Access 2003 to no
avail. May I suggest that you try a 'repaint' of the Order
form immediately after updating TotalPrice
e.g.
Me.Recalc
Forms!Order!TotalPrice = Me!TotalPrice
Forms!Order.Repaint

Regards

Gerald
 
Is the control TotalPrice on the main form bound to a field in the main
form's RecordSource? If not, simply set the ControlSource of this control to
be equal to the subform's control:
=[OrderItems_Subform]![TotalPrice]

(This assumes that the name of the subform control (the control that holds
the subform) is named OrderItems_Subform.) With this setup, the value should
be automatically updated when the value changes in the subform.

Else....
If the control on the main form is bound to a field, then your expression
should work. Is it giving you an error? Try this code step in place of the
one you're using:
Me.Parent!TotalPrice = Me!TotalPrice

Also, I note what may be a typo in your post:
"TotalPrice.Recordsource=Sum([Price])"

A control does not have a RecordSource. Perhaps this should read
ControlSource?
 
Hello Ken
Ken Snell said:
Is the control TotalPrice on the main form bound to a field in the main
form's RecordSource? If not, simply set the ControlSource of this control to
be equal to the subform's control:
=[OrderItems_Subform]![TotalPrice]
Its a Bound field.
(This assumes that the name of the subform control (the control that hold
the subform) is named OrderItems_Subform.) With this setup, the value should
be automatically updated when the value changes in the subform.

Else....
If the control on the main form is bound to a field, then your expression
should work. Is it giving you an error? Try this code step in place of the
one you're using:
Me.Parent!TotalPrice = Me!TotalPrice Thanks. Will try this.

Also, I note what may be a typo in your post:
"TotalPrice.Recordsource=Sum([Price])"

A control does not have a RecordSource. Perhaps this should read
ControlSource?
Your right. Should have read
"TotalPrice.ControlSource=Sum([Price])"
sorry for the confution.
--
Ken Snell
<MS ACCESS MVP>

Philip said:
Hello All
Have a simple problem with a subform.
I have a form called Order, and a subform called OrderItems_Subform. The
Subform is a continous form.
Simple enough.
when items (records) are added to the Subform, a field in the footer of the
subform is recalculated with me.recalc
The field in the footer part of the subform is
TotalPrice.Recordsource=Sum([Price]).
This works great.
However, I need to transfer that value to the Orders form. I need to do
this as soon as the recalc is done. (dynamic update for the user).
In the subform I have the following code on Price_AfterUpdate()

Me.Recalc
Forms!Order!TotalPrice = Me!TotalPrice

Problem is, the recalc updates the Me!TotalPrice in the subform no problem,
but the next line does not update the TotalPrice field in the Order form.
Why?

Strange thing is, if I put a break point in at me.recalc, then step through,
it updated the TotalPrice in the Order form OK.
???
What have I got to do between these two lines to make it work? The stepping
through is allowing enough time (or something) to happen, but just running
it isnt.

Help!

Thanks... Philip Middleton
 
Hello Gerrald.
Tried your suggestion of Repaint. No difference.
Nuthing errors, it just leaves the value of Forms!Order!TotalPrice as $0.00
The field is a bound field
checking the other suggetion now.
Gerald Stanley said:
Philip

I have tried to reproduce your problem on Access 2003 to no
avail. May I suggest that you try a 'repaint' of the Order
form immediately after updating TotalPrice
e.g.
Me.Recalc
Forms!Order!TotalPrice = Me!TotalPrice
Forms!Order.Repaint

Regards

Gerald
-----Original Message-----
Hello All
Have a simple problem with a subform.
I have a form called Order, and a subform called OrderItems_Subform. The
Subform is a continous form.
Simple enough.
when items (records) are added to the Subform, a field in the footer of the
subform is recalculated with me.recalc
The field in the footer part of the subform is
TotalPrice.Recordsource=Sum([Price]).
This works great.
However, I need to transfer that value to the Orders form. I need to do
this as soon as the recalc is done. (dynamic update for the user).
In the subform I have the following code on Price_AfterUpdate()

Me.Recalc
Forms!Order!TotalPrice = Me!TotalPrice

Problem is, the recalc updates the Me!TotalPrice in the subform no problem,
but the next line does not update the TotalPrice field in the Order form.
Why?

Strange thing is, if I put a break point in at me.recalc, then step through,
it updated the TotalPrice in the Order form OK.
???
What have I got to do between these two lines to make it work? The stepping
through is allowing enough time (or something) to happen, but just running
it isnt.

Help!

Thanks... Philip Middleton


.
 
Hello Ken
Ken Snell said:
Is the control TotalPrice on the main form bound to a field in the main
form's RecordSource? If not, simply set the ControlSource of this control to
be equal to the subform's control:
=[OrderItems_Subform]![TotalPrice]

(This assumes that the name of the subform control (the control that holds
the subform) is named OrderItems_Subform.) With this setup, the value should
be automatically updated when the value changes in the subform.

Its a bound field, but it does give me the idea of puting in a hidden field
with this as the ControlSource, and then making Forms!Order!TotalPrice =
Forms!Order!{InvisibleFieldName}
Else....
If the control on the main form is bound to a field, then your expression
should work. Is it giving you an error? Try this code step in place of the
one you're using:
Me.Parent!TotalPrice = Me!TotalPrice

No difference.
Also, I note what may be a typo in your post:
"TotalPrice.Recordsource=Sum([Price])"

A control does not have a RecordSource. Perhaps this should read
ControlSource?

Correct with the ControlSource. Oops. Sorry.

....

Tried something as above. Put a invisable field in Order form.
InvisiblePrice.ControlSource=[Order_Items Subform].Form!TotalPrice
Then something really weird happened.
Before I even write the code to make Forms!Order!TotalPrice =
Forms!Order!InvisiblePrice I accidently ran the form.
Bingo!
The Forms!Order!TotalPrice field was updated as it should be.
But I have not coded anything different! And I had not writen the code to
make Forms!Order!TotalPrice = Forms!Order!InvisiblePrice
OK. It works, so I dont really care, but I cant say I understand why. To
double check, I removed the field Forms!Order!InvisiblePrice, and it stopped
working again. Put it back and it works.

So, My problem has gone away, but I'm even more confused than ever.
I sware its the truth, but I cant understand it. Can anyone make heads or
tails of it?

I'm running Windows XP Pro SP1 with all critical updates.
I've got Office 2003 Pro running access database 2000 format.
P4 2Gig 512MB Reasonably fresh install, stable as a rock.

N.B. This is now only a curiosity, as this now works, and I can live with
this sollution..
--
Ken Snell
<MS ACCESS MVP>

Philip said:
Hello All
Have a simple problem with a subform.
I have a form called Order, and a subform called OrderItems_Subform. The
Subform is a continous form.
Simple enough.
when items (records) are added to the Subform, a field in the footer of the
subform is recalculated with me.recalc
The field in the footer part of the subform is
TotalPrice.Recordsource=Sum([Price]).
This works great.
However, I need to transfer that value to the Orders form. I need to do
this as soon as the recalc is done. (dynamic update for the user).
In the subform I have the following code on Price_AfterUpdate()

Me.Recalc
Forms!Order!TotalPrice = Me!TotalPrice

Problem is, the recalc updates the Me!TotalPrice in the subform no problem,
but the next line does not update the TotalPrice field in the Order form.
Why?

Strange thing is, if I put a break point in at me.recalc, then step through,
it updated the TotalPrice in the Order form OK.
???
What have I got to do between these two lines to make it work? The stepping
through is allowing enough time (or something) to happen, but just running
it isnt.

Help!

Thanks... Philip Middleton
 
I don't have any quick suggestion to explain what you're seeing, based on
your descriptions, but it seems unusual that this should make things work
now. Let me think about it some more and I'll post back if I get any ideas.

--
Ken Snell
<MS ACCESS MVP>

Philip said:
Hello Ken
Ken Snell said:
Is the control TotalPrice on the main form bound to a field in the main
form's RecordSource? If not, simply set the ControlSource of this
control
to
be equal to the subform's control:
=[OrderItems_Subform]![TotalPrice]

(This assumes that the name of the subform control (the control that holds
the subform) is named OrderItems_Subform.) With this setup, the value should
be automatically updated when the value changes in the subform.

Its a bound field, but it does give me the idea of puting in a hidden field
with this as the ControlSource, and then making Forms!Order!TotalPrice =
Forms!Order!{InvisibleFieldName}
Else....
If the control on the main form is bound to a field, then your expression
should work. Is it giving you an error? Try this code step in place of the
one you're using:
Me.Parent!TotalPrice = Me!TotalPrice

No difference.
Also, I note what may be a typo in your post:
"TotalPrice.Recordsource=Sum([Price])"

A control does not have a RecordSource. Perhaps this should read
ControlSource?

Correct with the ControlSource. Oops. Sorry.

...

Tried something as above. Put a invisable field in Order form.
InvisiblePrice.ControlSource=[Order_Items Subform].Form!TotalPrice
Then something really weird happened.
Before I even write the code to make Forms!Order!TotalPrice =
Forms!Order!InvisiblePrice I accidently ran the form.
Bingo!
The Forms!Order!TotalPrice field was updated as it should be.
But I have not coded anything different! And I had not writen the code to
make Forms!Order!TotalPrice = Forms!Order!InvisiblePrice
OK. It works, so I dont really care, but I cant say I understand why. To
double check, I removed the field Forms!Order!InvisiblePrice, and it stopped
working again. Put it back and it works.

So, My problem has gone away, but I'm even more confused than ever.
I sware its the truth, but I cant understand it. Can anyone make heads or
tails of it?

I'm running Windows XP Pro SP1 with all critical updates.
I've got Office 2003 Pro running access database 2000 format.
P4 2Gig 512MB Reasonably fresh install, stable as a rock.

N.B. This is now only a curiosity, as this now works, and I can live with
this sollution..
--
Ken Snell
<MS ACCESS MVP>

Philip said:
Hello All
Have a simple problem with a subform.
I have a form called Order, and a subform called OrderItems_Subform. The
Subform is a continous form.
Simple enough.
when items (records) are added to the Subform, a field in the footer
of
the
subform is recalculated with me.recalc
The field in the footer part of the subform is
TotalPrice.Recordsource=Sum([Price]).
This works great.
However, I need to transfer that value to the Orders form. I need to do
this as soon as the recalc is done. (dynamic update for the user).
In the subform I have the following code on Price_AfterUpdate()

Me.Recalc
Forms!Order!TotalPrice = Me!TotalPrice

Problem is, the recalc updates the Me!TotalPrice in the subform no problem,
but the next line does not update the TotalPrice field in the Order form.
Why?

Strange thing is, if I put a break point in at me.recalc, then step through,
it updated the TotalPrice in the Order form OK.
???
What have I got to do between these two lines to make it work? The stepping
through is allowing enough time (or something) to happen, but just running
it isnt.

Help!

Thanks... Philip Middleton
 
Back
Top