Trying to show correct record count on Form Load

D

Dirk

I'm working with Access 2002 and I'm able to show a count of records
using a label on a form without using the Access navigational buttons.
I have created my own custom navigational command buttons. The label
works fine except when the form loads for the first time. The label
displays that I have 50 records when I really have over 400. Once I
start navigating using custom buttons, the record count appear
correctly and remains correct during other operations (adding new
record, deleting record etc.). It's only when the form loads for the
first time. This is the code I've used in the Form_Current event
handler.

Dim rs As Recordset
Dim rc As Long
Set rs = Me.RecordSetClone
With rs
.MoveFirst
.MoveLast
rc = .RecordCount
End With
Me.label46 = "Record " & Me.CurrentRecord & " of " & rc

Do I need to add code to the Form_Load Event. Any help would be
greatly appreciated.

Dirk
 
G

Guest

Hi Dirk,

I've created Text Boxes like you are trying to with a Lable, so that I don't
need to use the navigation buttons...

The code that I use is:

me.controlId = Me.CurrentRecord & " Of " & Me.RecordsetClone.RecordCount

Where controlID would be the Text Box name. The code is placed in the On
Current event for the form. You can prevent users clicking in the text box
by setting the Locked and Enabled properties appropriately.

HTH

Tim
 
A

Andi Mayer

.............
first time. This is the code I've used in the Form_Current event
handler.

the last Line of the onOpen should point to your FormCurrent

there you can be shure that the recordsource is filled up.

I would change the FormCurrent to:

With Me.RecordsetClone
if .recordcount >0 then .MoveLast
rc = .RecordCount
End With
Me.label46 = "Record " & Me.CurrentRecord & " of " & rc


If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW
 

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