Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record x of y

Status
Not open for further replies.

xtraterrestrial

Programmer
Sep 23, 2003
38
CA
I'm created my own navigation button on a form and disabled the navigation buttons. I would like to have the "Record x of y" caption on the form. Can someone share some code that will do this for me?

Thanks
 
try...

in the On Current proc of the form...

place a text box on the form (name it Text1 for example purposes)

Text1 = me.CurrentRecord & " of " & me.RecordsetClone.Recordcount

hope this helps.
 
sorry a bit out of order

place a text box on the form (name it Text1 for example purposes)

in the On Current proc of the form enter the following...

Text1 = me.CurrentRecord & " of " & me.RecordsetClone.Recordcount


hope this helps.
 
xtraterrestrial

To do this, you have to manually run to things...

First upon a load and apply filter events, you need to run a count of the number records for the record set. This will be your Y number. There are numerous variations...

I am going to assume you have two text fields on the form
Me.intYCount
Me.intXPosition

Dim intYCount As Integer, strSQL As String

'Need to determine you where clause for this example
'For the entire record set, use something that will retrieve all records
strSQL = "xxxVariable > 0"
strSQL = "xxxVariable not null"
strSQL = "xxxVariable = " & YourFilter

Me.RecordsetClone.FindFirst strSQL
If Not Me.RecordsetClone.NoMatch Then
Me.RecordsetClone.MoveLast
intYCount = Me.RecordsetClone.RecordCount
Me.RecordsetClone.MoveFirst
Me.intYCount = intYCount
Me.intXPosition = 1
End If



Second, you need to track the ralative position. Perhaps a simple way would be to use an unbound text field. Set it to 0 (at the same time you run your count - on the load and after applying a filter).

With the forward button
Me.intXPosition = Me.intXPosition + 1

For the back button
Me.intXPosition = Me.intXPosition -1

So not to look funny, you will probably need some logic...

If Me.intXPosition < 1 then Me.intXPosition = 1
and
If Me.intXPosition > Me.intYCount then Me.intXPosition = Me.intYCount


I have not used this code so you may have to tweak it to get it work.

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top