Request for help - Displaying current record count with bookmarks

gellerche

Registered User.
Local time
Today, 17:57
Joined
Jun 19, 2001
Messages
73
I have a form that displays search results. The user can click First, Next, Previous, and Last to go through the records. This works fine, and the correct data is shown in the correct order. I am having a problem with displaying the count of the current record in a "1 out of 6" format. Here is the background:

The form gets its data from PubMonthlyProgressRS, and always opens on the first record of that RS. There are fields at the top of the form arranged like this:
txtRecordCurrent "out of" txtRecordTotal
If the search only pulls up one record, the display is correct "1 out of 1". If there's > 1 record, the first number is always 2. If any button is clicked, it always changes to the max, and stays that way. For example, this is what's shown with a RS of 6 records:

2 out of 6 (with 1st record showing)
Click Next or Last
6 out of 6 (with Next/Last record showing)
Click First or Previous
6 out of 6 (with First /Previous record showing)

Here's the code I'm using (called each time a button is clicked):
Dim DummyRS As DAO.Recordset
Set DummyRS = PubMonthlyProgressRS.Clone
DummyRS.Bookmark = PubMonthlyProgressRS.Bookmark
txtRecordCurrent.Value = DummyRS.RecordCount
DummyRS.MoveLast
txtRecordTotal.Value = DummyRS.RecordCount
DummyRS.Close

Can someone please tell me what I'm doing wrong?

Thanks,

Steve Geller
 
Me.txtCurrRec = Form.CurrentRecord
Me.txtTotalRecs = Form.RecordsetClone.RecordCount + IIf(Form.NewRecord, 1, 0) & " " & "(filtered)"
 
Rich:

I replaced my code with yours, and now it says "1 out of 1", regardless of the number of records or placement in the rs. Any ideas?

Thanks,

Steve Geller
 
I did, but with the same results. This may or may not be due to each time the user clicks a button, I call the Form_Load event. Could this be the problem?
 
Finally got it to work:

Here's the code for anyone who has to do this in the future:

Dim DummyRS As DAO.Recordset
Set DummyRS = PubMonthlyProgressRS.Clone
txtRecordCurrent.Value = PubMonthlyProgressRS.AbsolutePosition + 1
DummyRS.MoveLast
txtRecordTotal.Value = DummyRS.RecordCount
DummyRS.Close

Thanks for your help, Rich.
 

Users who are viewing this thread

Back
Top Bottom