Calculated subform

N

NCole

I have a main form that has several tab controls that
contain subforms. On one subform I have calculated
control to show the last record. I want to update a field
on the main form with the contents of the calculated
form. I did this by simply making the main form field
equal to the calculated control on the subform. I added
this code to the oncurrent of the main form and the
afterupdate of the calculated control on the subform.
This works well but it has one problem. It seems to
update to the record right before the correct record. I
would appreciate any help. Thanks!
 
N

NCole

Through more investigation I found that isn't refreshing
the calculated control fast enought, so it copies what was
in the control before the afterupdate. I am still unable
to get this code to work right. I think it needs some
type of pause while it refreshes then the code could
continue after it refreshes. I still need help.

Thanks for the support,
NCole
 
M

Marshall Barton

NCole said:
Through more investigation I found that isn't refreshing
the calculated control fast enought, so it copies what was
in the control before the afterupdate. I am still unable
to get this code to work right. I think it needs some
type of pause while it refreshes then the code could
continue after it refreshes. I still need help.

Thanks for the support,
NCole

I think I've seen that with a text box expression that
refers to a calculated subform control, especially if there
is a lot of other stuff going on.

You never did say what code you're using, but timing issues
can occasionly interfere with the main form's current event
synchronizing with a subform's calculated controls. Instead
of using control expressions to do this, you might want to
try using code in the subform's current event and some(?)
controls' AfterUpdate event to calculate the value and store
it directly back to the main form's text box.
 
N

NCole

-----Original Message-----


I think I've seen that with a text box expression that
refers to a calculated subform control, especially if there
is a lot of other stuff going on.

You never did say what code you're using, but timing issues
can occasionly interfere with the main form's current event
synchronizing with a subform's calculated controls. Instead
of using control expressions to do this, you might want to
try using code in the subform's current event and some(?)
controls' AfterUpdate event to calculate the value and store
it directly back to the main form's text box.

You hit it right on the nose. The only code that is being
used for this is to set the mainforms text box equal to
the subform's calculated control. The code is in the
OnCurrent of the mainform and the AfterUpdate of the
control that gives the information to the calculated
control. Basically it says

Forms!frmEmployeeRecord.CurrentDate = _
Forms!frmEmployeeRecord!frmEmployeePosition.Form!LastDate

All it does is copy the info in [LastDate] to
[CurrentDate].

I am a beginner on this and am not familiar with the code
that you spoke of. More help would greatly be appreciated.

Thanks,

NCole
 
M

Marshall Barton

NCole said:
You hit it right on the nose. The only code that is being
used for this is to set the mainforms text box equal to
the subform's calculated control. The code is in the
OnCurrent of the mainform and the AfterUpdate of the
control that gives the information to the calculated
control. Basically it says

Forms!frmEmployeeRecord.CurrentDate = _
Forms!frmEmployeeRecord!frmEmployeePosition.Form!LastDate

All it does is copy the info in [LastDate] to
[CurrentDate].

I am a beginner on this and am not familiar with the code
that you spoke of. More help would greatly be appreciated.

What is the expression in the subreport's calculated text
box? That's what we have to convert into code in the
appropriate places so we can "push" the result into the main
form (instead of trying to get the main form to "pull" the
value into itself).
 

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