Trouble with Control

C

Chaplain Doug

Access 2003. I have a main form with a subform. These
forms are linked together (Master-Child). A text control
on the subform is to display the record count of the
recordset of the subform. I use:

Control Source: =Form.Recordset.RecordCount

Another is to display the current record of the subform.
I use:

Control Source: =Form.CurrentRecord

When I move from record to record in the main form, I
expect these controls in the subform to update
accordingly. However, the control that is to display the
total number of records in the sunform record set does not
display the proper number until I actually advance records
in the subform.

To make it clearer:

When I advance to a record in the main form that has five
records in the subform, the subform displays:

Record 1 or 1

Then when I advance a record in the sunform, it properly
displays:

Record 2 of 5

What am I doing wrong? Thanks.
 
G

Graham Mandeno

Hi Doug

It sounds like a timing problem in the synchronisation between the loading
of the subform's recordset and the updating of the recordcount textbox. Try
putting this in the main form's Form_Current event procedure:

DoEvents
Me![name of subform control].Form![name of recordcount textbox].Requery
 
D

Dirk Goldgar

Chaplain Doug said:
Access 2003. I have a main form with a subform. These
forms are linked together (Master-Child). A text control
on the subform is to display the record count of the
recordset of the subform. I use:

Control Source: =Form.Recordset.RecordCount

Another is to display the current record of the subform.
I use:

Control Source: =Form.CurrentRecord

When I move from record to record in the main form, I
expect these controls in the subform to update
accordingly. However, the control that is to display the
total number of records in the sunform record set does not
display the proper number until I actually advance records
in the subform.

To make it clearer:

When I advance to a record in the main form that has five
records in the subform, the subform displays:

Record 1 or 1

Then when I advance a record in the sunform, it properly
displays:

Record 2 of 5

What am I doing wrong? Thanks.

What happens if you use

=Count(*)

as the controlsource for the record count text box, instead of

=Form.Recordset.RecordCount

?
 
C

Chaplain Doug

=Count(*) works. But, I was able to get
Recordset.recordcount to work after I reset the
recordsource for the subform. I basically redefined the
recordsource and then set it back to what it was
originally, then reran the form and it worked. Oh well...
 

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