requery

G

greg

Can someone see something wrong here?

I have a form that has a control [lbrEntry]. On that form
is a subform ([frmLbrPaid]).

[lbrEntry] is my labor entry and my subform shows sum of
entries. I want the subform to include current
[lbrEntry]. I have placed the following code in
[lbrEntry]:


Private Sub lbrEntry_AfterUpdate()
Me.frmLbrPaid.Form!SumLabor.Requery
End Sub

Leaving the entry field does not update the [SumLabor] on
my subform. However, closing and reopening the form does.
Seems like a requery issue, but how so? I cannot figure
it out.

Please help,
Thanks.
 
R

Rick Brandt

greg said:
Can someone see something wrong here?

I have a form that has a control [lbrEntry]. On that form
is a subform ([frmLbrPaid]).

[lbrEntry] is my labor entry and my subform shows sum of
entries. I want the subform to include current
[lbrEntry]. I have placed the following code in
[lbrEntry]:


Private Sub lbrEntry_AfterUpdate()
Me.frmLbrPaid.Form!SumLabor.Requery
End Sub

Leaving the entry field does not update the [SumLabor] on
my subform. However, closing and reopening the form does.
Seems like a requery issue, but how so? I cannot figure
it out.

You need to save the main record before the subform's expression will pick it up.

Private Sub lbrEntry_AfterUpdate()
Me.Dirty = False
Me.frmLbrPaid.Form!SumLabor.Requery
End Sub
 
R

Rick Brandt

greg said:
Rick, thanks for the help. I placed that line in the
code. It does not change the subform's field
unless/until I move to another entry field and return.
When I click on the entry field after having left it, it
updates the suform's field.

Do you know how to solve? Thanks.

Well, you're using the AfterUpdate event and that event doesn't fire until the
control is updated. Without leaving the current record or closing the form, the only
thing that causes the control to update is moving to another control. If that is not
acceptable you could use the Change event, but that will fire with every keystroke so
I would not recommend it.
 
G

greg

Yes, updating upon leaving the field is AOK. I know that
means I must enter another field.

Here's behaviour after entering the amount and using
these methods to leave that field:

1. enter key - accepts entry, moves to next field, no
update.

2. click on next field - accepts entry, "calculating"

3. tab to next field - accepts entry, "calculating"

In each case the sum field updates only if I return to
the entry field via shift-tab or click.

I'm hoping this is obvious to you.

Thanks again for helping.




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


Well, you're using the AfterUpdate event and that event doesn't fire until the
control is updated. Without leaving the current record or closing the form, the only
thing that causes the control to update is moving to
another control. If that is not
 
R

Rick Brandt

greg said:
Yes, updating upon leaving the field is AOK. I know that
means I must enter another field.

Here's behaviour after entering the amount and using
these methods to leave that field:

1. enter key - accepts entry, moves to next field, no
update.

2. click on next field - accepts entry, "calculating"

3. tab to next field - accepts entry, "calculating"

In each case the sum field updates only if I return to
the entry field via shift-tab or click.

Don't understand that. Can you tell if the record is saving when you leave the
control?
 

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