G
Guest
My reading of Access Help on Requery has me confused. Help seems to say that
control.Requery should work in my application but I've found form.Recalc is
the only solution.
I have a simple continuous form where the user can update a Salary field.
In the form header is a calculated control, a textbox
Text6 ControlSource =Format(DSum("Salary","Employees"),"$0.00")
which will show the user the current total of the salaries on file. Text6
is re-updated, via the Salary field AfterUpdate event, each time the user
enters a new salary to the form .
Private Sub Salary_AfterUpdate()
' update the sum
If Me.Dirty Then
Me.Dirty = False
End If
Me![Text6].Requery
End Sub
There are a few other calculated controls on the form (total employees etc)
which are set at the form's OnOpen event and don't change with the user's
salary input. So, I thought it would be a bit more efficient to requery
only the control that needs update, but it doesn't work (when the form opens
Text6 correctly shows the total at form open time but after each salary entry
it remains unchanged). In place of Me.Text6.Requery I'm using Me.Recalc
which works fine.
Help info on Requery says:
"Reruns the query on which the form or control is based.
Controls based on a query or table include:
Controls for which the ControlSource property setting includes domain
aggregate functions or SQL aggregate function.
If you specify any other type of control for the object argument, the record
source for the form is requeried.
If the control specified by the object argument isn't bound to a field in a
table or query, the Requery method forces a recalculation of the control."
- - - -
Since Text6 is based on domain aggregate funtion it seems it should update
with Requery.
While I'm happy with the Recalc approach I am puzzled why the Requery
doesn't work.
Any thoughts appreciated.
control.Requery should work in my application but I've found form.Recalc is
the only solution.
I have a simple continuous form where the user can update a Salary field.
In the form header is a calculated control, a textbox
Text6 ControlSource =Format(DSum("Salary","Employees"),"$0.00")
which will show the user the current total of the salaries on file. Text6
is re-updated, via the Salary field AfterUpdate event, each time the user
enters a new salary to the form .
Private Sub Salary_AfterUpdate()
' update the sum
If Me.Dirty Then
Me.Dirty = False
End If
Me![Text6].Requery
End Sub
There are a few other calculated controls on the form (total employees etc)
which are set at the form's OnOpen event and don't change with the user's
salary input. So, I thought it would be a bit more efficient to requery
only the control that needs update, but it doesn't work (when the form opens
Text6 correctly shows the total at form open time but after each salary entry
it remains unchanged). In place of Me.Text6.Requery I'm using Me.Recalc
which works fine.
Help info on Requery says:
"Reruns the query on which the form or control is based.
Controls based on a query or table include:
Controls for which the ControlSource property setting includes domain
aggregate functions or SQL aggregate function.
If you specify any other type of control for the object argument, the record
source for the form is requeried.
If the control specified by the object argument isn't bound to a field in a
table or query, the Requery method forces a recalculation of the control."
- - - -
Since Text6 is based on domain aggregate funtion it seems it should update
with Requery.
While I'm happy with the Recalc approach I am puzzled why the Requery
doesn't work.
Any thoughts appreciated.