Number of record retrieved on a form

C

Catherine M

How do you place in a variable the record count for the
form, i.e. number of records retrieved? I would think
that it is a property of the form. If the form uses the
record navigation buttons this number displays so it
should be programmatically available. If you apply a
filter where do you get the count of the number of
filtered records? I have done database application
programming before but not with Access and VBA. I am
finding it very hard to get answers using Help to what I
consider fairly simple questions.
 
C

Cheryl Fischer

You can use the form's RecordsetClone.RecordCount property. For example, if
you had a label control on your form named: lblNavigate, you could put the
following code in the On Current event of your form to duplicate the Record
Navigation functionality supplied by Access.


Dim lngrecordnum As Long

lngrecordnum = Me.CurrentRecord
If Me.NewRecord Then
Me!lblNavigate.Caption = "New Record"
Else
With Me.RecordsetClone
.Bookmark = Me.Bookmark
End With
Me!lblNavigate.Caption = "Record " & Me.CurrentRecord & " of " &
Me.RecordsetClone.RecordCount
End If



hth,
 
G

Guest

Thanks for your help.

Catherine
-----Original Message-----
You can use the form's RecordsetClone.RecordCount property. For example, if
you had a label control on your form named: lblNavigate, you could put the
following code in the On Current event of your form to duplicate the Record
Navigation functionality supplied by Access.


Dim lngrecordnum As Long

lngrecordnum = Me.CurrentRecord
If Me.NewRecord Then
Me!lblNavigate.Caption = "New Record"
Else
With Me.RecordsetClone
.Bookmark = Me.Bookmark
End With
Me!lblNavigate.Caption = "Record " & Me.CurrentRecord & " of " &
Me.RecordsetClone.RecordCount
End If



hth,
--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX





.
 

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