The recordcount property doesn't work. I have values different from 0 even if the database is empty. And if I use .BOF I have an error!
Thanks
Printable View
The recordcount property doesn't work. I have values different from 0 even if the database is empty. And if I use .BOF I have an error!
Thanks
have you tried checking .eof ?
I have tried so many times to try and use .RecordCount for a recordset and it just is not consistent. I am assuming you are using ADO, but if not, it doesn't matter; same concept applies.
Soo.... I have changed to doing a count of the records that would be returned with a regular recordset first, because it is very fast, and if I don't have to hit the database to get the big load of stuff, if I don't have to then, alrgight.
What I'm saying is this... (Yes you may hit the DB twice), but it may be worth it.
Use some field name that is in your table to simply get the number of records in the recordset. Don't use the Count(*) method because then it has to search the Fields collection of the database and examine all the fields. Then, use thisCode:"ssql = "Select Count(ID) From Names Where State = 'CA'"
This will tell you how many records you have by, 1) not having to do a .MoveLast and open you RS in a non-forwardonly fashion, 2) it lets you make a decision.Code:if ors.Fields(1) > 0 then
ssql = Select ID, Last, First from Names Where State = 'CA'
ors.open ssql, oConn, adforwardonly
...
end if
Hope the info helps for something.