Subform Problem

R

RBDU

Hi All! thanking anyone for a reply. A97.

I have a subform (datasheet) on my mainform, linked by [ID] that is
visible - No.

When the user gets clicks on a button to add [operator names] the subform
becomes visible.

The subform has two columns and when data is entered in the first column the
second column counts the data.
This column is hidden.

On the main form I have a reference in an unbound textbox, called [total]
which takes the total count in the subform. This is not visible and updates
straight away with the correct total on exiting the subform.

On the subform exit, the subform becomes invisible.

Now, on the main form I have the field [numberofoperators] which is:

Me.numberofoperators = Me.total

but this does not update straight away where the unbound text box does.

Is this because the subform is set to invisible on exit where if it was
closed the updating of the field [numberofoperators] would be updated
correctly.

How do I get it to update correctly?

Regards Peter McCartney
 
M

Marshall Barton

RBDU said:
I have a subform (datasheet) on my mainform, linked by [ID] that is
visible - No.

When the user gets clicks on a button to add [operator names] the subform
becomes visible.

The subform has two columns and when data is entered in the first column the
second column counts the data.
This column is hidden.

On the main form I have a reference in an unbound textbox, called [total]
which takes the total count in the subform. This is not visible and updates
straight away with the correct total on exiting the subform.

On the subform exit, the subform becomes invisible.

Now, on the main form I have the field [numberofoperators] which is:

Me.numberofoperators = Me.total

but this does not update straight away where the unbound text box does.

Is this because the subform is set to invisible on exit where if it was
closed the updating of the field [numberofoperators] would be updated
correctly.


The reason that your code is not updating the
numberofoperators correctly is that the control expression
calculations are done in a separate task that runs at a
lower priority than VBA code execution. This means that you
have no way to synchronize the calculation and your code to
retrieve the calculated value.

Try making the Total text box visible so you can see the
calculated value. Then make the numberofoperators text box
invisible so it doesn't confuse users. To get the
calculated value into the table field try moving your line
of code to the form's BeforeUpdate event, which is the
latest possible time to set the numberofoperators bound text
box.
 
R

RBDU

Thanking you!

Marshall Barton said:
RBDU said:
I have a subform (datasheet) on my mainform, linked by [ID] that is
visible - No.

When the user gets clicks on a button to add [operator names] the subform
becomes visible.

The subform has two columns and when data is entered in the first column the
second column counts the data.
This column is hidden.

On the main form I have a reference in an unbound textbox, called [total]
which takes the total count in the subform. This is not visible and updates
straight away with the correct total on exiting the subform.

On the subform exit, the subform becomes invisible.

Now, on the main form I have the field [numberofoperators] which is:

Me.numberofoperators = Me.total

but this does not update straight away where the unbound text box does.

Is this because the subform is set to invisible on exit where if it was
closed the updating of the field [numberofoperators] would be updated
correctly.


The reason that your code is not updating the
numberofoperators correctly is that the control expression
calculations are done in a separate task that runs at a
lower priority than VBA code execution. This means that you
have no way to synchronize the calculation and your code to
retrieve the calculated value.

Try making the Total text box visible so you can see the
calculated value. Then make the numberofoperators text box
invisible so it doesn't confuse users. To get the
calculated value into the table field try moving your line
of code to the form's BeforeUpdate event, which is the
latest possible time to set the numberofoperators bound text
box.
 

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