Update Main form from continuous subform

  • Thread starter Jeff via AccessMonster.com
  • Start date
J

Jeff via AccessMonster.com

I have a Main form (FR_Main Form) which has a tab control on which I have a
continuous subform (FR_QualityChecks). On the footer of the subform (hidden)
I have some calculations and subtotals which results are used to update a
text box (TabQuality) on the Main form.

I have the following code to update the text box TabQuality on the after
update event of the subform:
[Line] in the following is a combo box on the Main Form

Private Sub Form_AfterUpdate()
If Nz(Parent.[Line]) = True Then
Parent.[TabQuality] = ""
Else:
If [Forms]![FR_Main Form]![FR_QualityChecks].[Form]![0s] > 0 Then
Parent.[TabQuality] = 1
Else:
If ([Forms]![FR_Main Form]![FR_QualityChecks].[Form]![3s]) >
0 Then
Parent.[TabQuality] = 2
Else: Parent.[TabQuality] = 0
End If
End If
End If
End Sub
Everytime I fill out a value on the subform FR_QualityChecks, the subtotal
fields [0s] and [3s] change and based on their value it should update
[Tabquality]
It works except that Tabquality updated only after the 2nd input on the
subform. It is always updating the Main form one entry late
I have tried to requery the subform after input with any or all of the
following code but it makes no difference

Me.Requery
Parent.[TabQuality].Requery
Me.TabQualityValue.Requery
Parent.[TabQuality] = Me.TabQualityValue
Parent.[TabQuality].Requery
Me.TabQualityValue.Requery
Me.Requery

I need theTabQuality to update right after the entru on the subform is done.
Any Idea??
 
J

Jeff via AccessMonster.com

Stupid question? or too difficult to do?
I have a Main form (FR_Main Form) which has a tab control on which I have a
continuous subform (FR_QualityChecks). On the footer of the subform (hidden)
I have some calculations and subtotals which results are used to update a
text box (TabQuality) on the Main form.

I have the following code to update the text box TabQuality on the after
update event of the subform:
[Line] in the following is a combo box on the Main Form

Private Sub Form_AfterUpdate()
If Nz(Parent.[Line]) = True Then
Parent.[TabQuality] = ""
Else:
If [Forms]![FR_Main Form]![FR_QualityChecks].[Form]![0s] > 0 Then
Parent.[TabQuality] = 1
Else:
If ([Forms]![FR_Main Form]![FR_QualityChecks].[Form]![3s]) >
0 Then
Parent.[TabQuality] = 2
Else: Parent.[TabQuality] = 0
End If
End If
End If
End Sub
Everytime I fill out a value on the subform FR_QualityChecks, the subtotal
fields [0s] and [3s] change and based on their value it should update
[Tabquality]
It works except that Tabquality updated only after the 2nd input on the
subform. It is always updating the Main form one entry late
I have tried to requery the subform after input with any or all of the
following code but it makes no difference

Me.Requery
Parent.[TabQuality].Requery
Me.TabQualityValue.Requery
Parent.[TabQuality] = Me.TabQualityValue
Parent.[TabQuality].Requery
Me.TabQualityValue.Requery
Me.Requery

I need theTabQuality to update right after the entru on the subform is done.
Any Idea??
 
M

Marshall Barton

I could swear that I answered this, but maybe it was the
same problem in another thread???

It's not a stupid question but it can be very difficult to
do. The problem is that VBA code runs at a much higher
priority than control calculations (which in turn run at a
higher priority than redrawing the form with the updated
value).

What that means is that you can not use VBA code to copy the
value of a claculated control. Either the main form control
must use an expression that refers to the subform calculated
control OR use VBA to do the subform control's calculation.
Either way both controls must be calculated at the same
priority level.
--
Marsh
MVP [MS Access]

Stupid question? or too difficult to do?
I have a Main form (FR_Main Form) which has a tab control on which I have a
continuous subform (FR_QualityChecks). On the footer of the subform (hidden)
I have some calculations and subtotals which results are used to update a
text box (TabQuality) on the Main form.

I have the following code to update the text box TabQuality on the after
update event of the subform:
[Line] in the following is a combo box on the Main Form

Private Sub Form_AfterUpdate()
If Nz(Parent.[Line]) = True Then
Parent.[TabQuality] = ""
Else:
If [Forms]![FR_Main Form]![FR_QualityChecks].[Form]![0s] > 0 Then
Parent.[TabQuality] = 1
Else:
If ([Forms]![FR_Main Form]![FR_QualityChecks].[Form]![3s]) >
0 Then
Parent.[TabQuality] = 2
Else: Parent.[TabQuality] = 0
End If
End If
End If
End Sub
Everytime I fill out a value on the subform FR_QualityChecks, the subtotal
fields [0s] and [3s] change and based on their value it should update
[Tabquality]
It works except that Tabquality updated only after the 2nd input on the
subform. It is always updating the Main form one entry late
I have tried to requery the subform after input with any or all of the
following code but it makes no difference

Me.Requery
Parent.[TabQuality].Requery
Me.TabQualityValue.Requery
Parent.[TabQuality] = Me.TabQualityValue
Parent.[TabQuality].Requery
Me.TabQualityValue.Requery
Me.Requery

I need theTabQuality to update right after the entru on the subform is done.
Any Idea??
 

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