Record number and position in a form

S

salmonella

I would like to create custom controls for showing how many records are
feeding a form and which record of the group is current (i.e. record 5 of
1200). I can use an ADO generated recordset or Dcount to show how many
records there are but I have no idea how to tell which record in the set is
currently open in the form.
Secondly, I am not even sure my approach with ADO recordsets is the way to go.

Can anyone point me in the right direction for creating these two things?


Thanks!
 
T

TC

Why not just enable the form's RecordSelectors and NavigationButtons
properties? Then Access will automatically show you which record is
current, and the total # of records. This would be way easier than
trying to re-code that, yourself.

HTH,
TC
 
B

BruceM

This is a method I have used. Create two unbound text boxes (txtCurrent and
txtTotal). In the forms's Current event:

Me.txtCurrent = Me.CurrentRecord
Me.RecordsetClone.MoveLast
Me.txtTotal = Me.RecordsetClone.RecordCount

You can hide the text boxes and refer to their values. For instance,
another unbound text box could be named txtCounter. The form's Current
event could include:
Me.txtCounter = Me.txtCurrent & " of " & Me.txtTotal

I expect you could also define Me.CurrentRecord and
Me.RecordsetClone.RecordCount as strings, and eliminate txtCurrent and
txtTotal (referring to the strings instead of the text boxes in the
txtCounter code), although I have not tried that.
 
S

salmonella

BruceM said:
This is a method I have used. Create two unbound text boxes (txtCurrent and
txtTotal). In the forms's Current event:

Me.txtCurrent = Me.CurrentRecord
Me.RecordsetClone.MoveLast
Me.txtTotal = Me.RecordsetClone.RecordCount

You can hide the text boxes and refer to their values. For instance,
another unbound text box could be named txtCounter. The form's Current
event could include:
Me.txtCounter = Me.txtCurrent & " of " & Me.txtTotal

I expect you could also define Me.CurrentRecord and
Me.RecordsetClone.RecordCount as strings, and eliminate txtCurrent and
txtTotal (referring to the strings instead of the text boxes in the
txtCounter code), although I have not tried that.
 
S

salmonella

Hi Bruce,

Many Thanks!

I did a quick test of it and it worked fine... I think that will do it, and
it is a lot cleaner than how i was doing it.

Many, Many thanks!!
 
S

salmonella

thanks for the thought, however for design reasons I really needed them in
the form header and of a particular style

thanks agian,
 
B

BruceM

You're very welcome. Glad to pass along something that I got from this
group some while ago.
 
Top