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

Count records in a linked subform.

Status
Not open for further replies.

Albion

IS-IT--Management
Aug 8, 2000
517
US
I have a form with a subform in it. The form contains companies and the sobform contains contacts at each company. I would like to get a count of only the total records in the current subform, not the entire table. I would prefer to use ADO instead of DAO if it is necessary.

I've tried

Dim rst As ADODB.RecordSet
Set rst = Me.sfrmContacts.Form.RecordsetClone
Me.text01 = rst.RecordCount

But I always get an error at the "set rst" line.

Any help would be appreciated.

-Al
 
Your problem may be that the recordset clone is a DAO.Recordset type.
 
Ok, is there someplace I can look to find the ADO equiv. of that? I am just starting to learn ADO over DAO because I've heard DAO is going away.

thanks

-Al
 
I would imagine that as long as there are recordset clones, there will be DAO.

Should the datatype of the recordset clone change, you will have to update your code.


That is all assuming I was correct in assuming that a recordsetclone is indeed a DAO.Recordsetclone. Did you try it?
 
It works DAO but I want to convert it to ADO. I've read so much about DAO not existing in later versions of software so I wanted to convert everything over.

-Al
 
Hi,

I am using this snippet of code to do the same thing you want. I am pulling my subform records from a query, I don't know how you are getting your subform's records. Paste this code behind an unbound text box (it will be the unbound text box's control source) on the subform footer:

=Forms!MainForm.SubForm.Form.Recordset.RecordCount

Hope it works for you,

jbehrne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top