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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record Count 1

Status
Not open for further replies.

Keberhard

Programmer
Mar 11, 2002
19
0
0
US
I am needing to display the current record number and the number of records on a form. Ex: Purchase 1 of 5.
I know that setting a text box =[CurrentRecord] works to get the current record but how do I get the total number of records.
I've tried
* =[RecordCount]
*creating a query that gets the record count and trying to display that field on the form.
Neither of these seem to be working.
Any ideas?

 
In the OnCurrent Event try putting in this code:

Dim db As Database
Dim rs As Recordset
Dim r_count As Integer

Set db = CurrentDb
Set rs = db.OpenRecordset("Segments")

r_count = rs.RecordCount

Me.textboxname.Value = r_count

 
Forgot to mention...

Where I have shown:
Set rs = db.OpenRecordset("Segments")

You need to change "Segments" to whatever table your form's content is based on. If you've used the query builder to get the form's records, then just add the following to the code...
In the declaration of variables -->
Dim sSQL As String

In the body -->
sSQL = Me.RecordSource
Set rs = db.OpenRecordset(sSQL)

I'm by no means an efficient programmer, so surely there's an easier or more logical way of doing this. Let me know if you need further assistance.
 
Hi!

You can also set a text box's control source to:

=DCount("YourIDField", "RecordSourceOfForm")

hth
Jeff Bridgham
bridgham@purdue.edu
 
You can also do this in a field. I think its probably the easiest.
=[CurrentRecord] & "of " & Count(*)

However, my question is, how do u get the currentrecord number in a continuous form?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top