Question : Need help with DAO recordset connection

Hi

Ok I haven't used Access for years but I'm back in it now and simply trying to get the record count for a table in an external database...it doesn't work, here is my simple code......

Dim dbproject As DAO.Database
Dim rst As DAO.Recordset

Set dbproject = ("C:\Documents and Settings\Testing\Desktop\Helpdesk Projects DB")
Set rst = dbproject.OpenRecordset("ProjectTable", dbOpenDynaset)

MsgBox rst.RecordCount



I tried it inside the Helpdesk Projects DB database as well and a weird thing happened it gave me the recordcount result as 1 no matter how many records are in the table.

any help will be appreciated

also, if anyone can let me know....can I use the DoCmd object within the DAO connection code or do I have to stick with the DAO type library? I'm pretty dumb when it comes to access programming

thanks again

Answer : Need help with DAO recordset connection

EverythingVB,

before you can open the table as recordset, you have to open the database first as
naftaligreenwald posted

Dim dbproject As DAO.Database
Dim rst As DAO.Recordset

Set dbproject = opendatabase("C:\Documents and Settings\Testing\Desktop\Helpdesk Projects DB")
Set rst = dbproject.OpenRecordset("ProjectTable", dbOpenDynaset)

if rst.eof then exit sub

rst.movelast
MsgBox rst.RecordCount


Random Solutions  
 
programming4us programming4us