Rowcount on Form

L

Larry

I am trying to get the rowcount for the form's recordset
in the open event of the form.

I basically do the following. Note, the error happens on
the SET step and in the MDB and MDE.

dim rst as dao.recordset

set rst = Me.recordset
irows = rst.recordcount

This works on some PC's and not others. On the one's it
does not work, I get an error "ActiveX control can't be
created"

I have verified that the reference files exist in the same
location on the PC's that do not work (basically DAO3.6
and ADO 2.1).

All I am trying to do is get the total rows returned to
the form initially on open. Any help would be greatly
appreciated.

Larry
 
D

Doug

Larry,

Open the record set on the table or query your form is
based on first. Then do a move last and then do the record
count.


dim cnt as long
dim rs as recordset
set rs = currentdb.openrecordset("Table Name")
rs. movelast
cnt = rs.recordcount

Hope this helps,
Doug
 
K

Ken Snell

Oftentimes, the recordset isn't loaded during the open event. Move your code
to the Load event and see if that's better. Also, I usually use the
RecordsetClone instead of the recordset, as its record count (I've found)
tends to be more accurate when the form is being set up. Recordset may not
show the correct record count unless you do a ".MoveLast" first.
 
L

Larry

Thanks to both responses. While both suggestions worked
on the PC's that worked before, I continue to get
the "ActiveX control can't be created" error.

I'm assuming this is the DAO Registry that performs this
function. I have verified that the files are in the same
location as defined in the registry. Any other
suggestions on determining why this works on some PC's and
not on others?

Thanks again for the quick responses yesterday!

Larry
 

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