Access 2000 requery on non-bound control

  • Thread starter Thread starter Tim Richardson
  • Start date Start date
T

Tim Richardson

In my main form I have a text box which shows the "amount" total of the
records in the subform.
When I navigate to a new header record (the main form) I would like
this subtotal to update to reflect the new records loaded into the
subform.
The unbound total text box uses a Dsum expression.

In my subform I get this to change correctly if the amount field in any
of subform records is changed, by code on the losefocus event which
does a refresh and then a requery on the unbound text box. This works
fine.

But when I navigate to new records in the main form, I don't know how
to make this total value update. At the moment I have on the "current"
event of the main form the code
me!journalTotal.requery
but this is not working even though I can see that this event is being
called whenever I naviate to a new record in the main form. So the
event is ok. And requerying that unbound control works when I do it in
the subform. It just doesn't work when I do it in the main form.
 
Hi Tim

In the subform's OnCurrent property, put this:

Forms!MainFormName.TextboxName =
Forms!MainFormName!SubformName.Form.RecordsetClone.RecordCount

This will keep the textbox updated with the correct count of records in the
subform at all times.

M
 
I tried the following and it seems to work: the text box in the main
form had the same name as the field in the table that it was bound to.
I changed the name of the text box to "JournalNbrBox" and changed the
Dsum accordingly, and now it works. Previously there was some ambiguity
I suppose, and for some reason whatever record or recordset the Dsum
was working with was not synchronised with the form when navigation
happens. Unexpected and obscure behaviour.
I will look into the current event in the subform; there is only one
field on the subform that can affect the subtotal, so I have a
loseFocus event on the field and I send a requery to the subtotal text
box which seems to work.
 
You should always name the text boxes differently to the field name.

If the field is called 'JournalNbr', then name the textbox txtJournalNbr.

M
 
Back
Top