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

Record Counter on Subform Label 3

Status
Not open for further replies.

cstuart79

Technical User
Nov 2, 2009
171
US
i would like to add a "record counter" on one of my subform labels. i are familiar with the navigation buttons but do not like them and would like to simply tally the number of records available. is there a way to do this?
 

Try this.

Private Sub Form_Current()
Label2.Caption = Me.Recordset.RecordCount
End Sub
 
Got run-time error 424:
Object required

after entering the following code:

Private Sub Form_Current()
DIRECT_CONNECT_Label.Caption = Me.Recordset.RecordCount
End Sub
 

Has the recordset been created the first time the Form_Current event fires?


Randy
 
How about this.

Private Sub Form_Current()
on error resume next
DIRECT_CONNECT_Label.Caption = Me.Recordset.RecordCount
End Sub
 
applied the code:

Private Sub Form_Current()
on error resume next
DIRECT_CONNECT_Label.Caption = Me.Recordset.RecordCount
End Sub

i didn't get any errors, but i don't see a visible "counter
 
randy,

are you saying to add the following code to "On Current" event as well?

Private Sub Form_Current()
on error resume next
DIRECT_CONNECT_Label.Caption = Me.Recordset.RecordCount
End Sub
 

I'm simply wondering when does the recordset get created. Is it after the form opens? I think the Form_Current event fires as soon
as the form opens. If the code to create the recordset has not yet run, it would seem an error would be generated. Perhaps if you
place the code to also run after the recordset has been promulgated?


Randy
 
added same code to "after update" event and still nothing is visible--no errors generated though.
 
If this is true "simply tally the number of records available" then why not just add a text box:
[tt][blue]
Control Source: =Count(*)
[/blue][/tt]
You may need to requery the text box in the after update event of the subform.

Duane
Hook'D on Access
MS Access MVP
 
wouldn't this give me a total of every record for every client? i am trying to get the total number of records on a per client basis. my table contains all client records, but i use a list box to select and view a specific client.
 
cstuart79,

You may have some special code there causing the error. I suggest creating one blank db with two tables and two forms to make a test.

Also, I just realized that DAO recordset gives a record count only on records that has been passed. So the correct code should be:

Private Sub Form_Current()
If Not Me.RecordsetClone.EOF Then
Me.RecordsetClone.MoveLast
End If
Label6.Caption = Me.RecordsetClone.RecordCount
End Sub

 
Entered the following code:

Private Sub Form_Current()
If Not Me.RecordsetClone.EOF Then
Me.RecordsetClone.MoveLast
End If
DIRECT_CONNECT_Label.Caption = Me.RecordsetClone.RecordCount
End Sub

Received the following error:

run-time error: object required
with DIRECT_CONNECT_Label.Caption = Me.RecordsetClone.RecordCount highlighted
 
duane,

got it in formheader but can't seem to get it to work as filtered in the label.
 
that's alright, i'll just adjust visually to keep it functional--thanks a ton duane!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top