Record pointer problem

A

Ashish Kanoongo

I am using an access bound database in which I am using a label on my form in which i am showing the current position of recordset with the code "lblRecordNavigation.Caption = Me.CurrentRecord & " of " & Me.RecordsetClone.RecordCount." and it shows N th record of total records (e.g. 3 of 5). now problem is whenever I try to add a new entry at the last it displays 6 of 5. plz tell me hat could be the way to display it 6 of 6 .
 
A

Allen Browne

When you are entering a new record, it has not been added yet.
You literally are at record 6 (a non-existent one) of a table that has 5
records.

If it's important to avoid that apparent blooper, you could use the Current
event of the form to test its NewRecord property and add 1 if necessary:

lblRecordNavigation.Caption = Me.CurrentRecord & " of " & _
(Me.RecordsetClone.RecordCount - CLng(Me.NewRecord))

BTW, would you be comfortable posting to fewer groups please? For example,
use the m.p.access groups rather than the m.p.office ones, and I'm not sure
how your question was related to virus group.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I am using an access bound database in which I am using a label on my form
in which i am showing the current position of recordset with the code
"lblRecordNavigation.Caption = Me.CurrentRecord & " of " &
Me.RecordsetClone.RecordCount." and it shows N th record of total records
(e.g. 3 of 5). now problem is whenever I try to add a new entry at the last
it displays 6 of 5. plz tell me hat could be the way to display it 6 of 6 .
 
W

Wayne Morgan

Where do you have this code placed, although since you're getting 6 for the record number it appears you are updating at an appropriate time. If you have Access 2000 or newer, try using Me.Recordset.RecordCount instead of the clone. If not, you may need to set an object variable to the clone first, then do a move last on it, followed by your current statement.

Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
rst.MoveLast
lblRecordNavigation.Caption = Me.CurrentRecord & " of " & rst.RecordCount
Set rst = Nothing

--
Wayne Morgan
MS Access MVP


I am using an access bound database in which I am using a label on my form in which i am showing the current position of recordset with the code "lblRecordNavigation.Caption = Me.CurrentRecord & " of " & Me.RecordsetClone.RecordCount." and it shows N th record of total records (e.g. 3 of 5). now problem is whenever I try to add a new entry at the last it displays 6 of 5. plz tell me hat could be the way to display it 6 of 6 .
 

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