DAO recordset

G

Guest

I opened a DAO recordset with the following rows. Althought the opened query
contains 2 records, the opened recordset'a recordcount is 1
(booked3.RecordCount = 1). This is a false value. But, after running the last
row (getrows), the booked3.recordcount = 2.

Why the booked3.recordcount = 1 after I opened the recordset?

" Set booked3 = dbs.OpenRecordset("SELECT Booked.* FROM Booked WHERE
(((Booked.[Cost Type])=70) AND ((Booked.[Cost Center])=11))", dbOpenSnapshot)
booked3.MoveFirst
bookeddb = booked3.RecordCount
bookt = booked3.GetRows(bookeddb)"

Thanks, Viktor
 
K

Keith Wilby

Juhaszv said:
Why the booked3.recordcount = 1 after I opened the recordset?

Because in VBA, Access doesn't know how many records there are until it has
found the last record. In fact, if you just open the recordset without
doing a MoveFirst, it won't even return a count of 1.

HTH - Keith.
www.keithwilby.com
 

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