SQL Returning Empty...

  • Thread starter Thread starter Ben Moore
  • Start date Start date
B

Ben Moore

I have a module that calculates job numbers for our record keeping
database. Within this module, I dim "rs" as DAO.Recordset and set it
equal to an SQL Query that I make.

My question is:
If the SQL Query finds no records, is "rs" set to null, or will
rs.MoveFirst return null? Will there be some sort of error if I try and
reference to rs.MoveFirst if it is null? (I know in Java it would result
in an NPE, but haven't thrown VBA around enuf.)

Any insight on this matter will be greatly appreciated. Thank you in
advance.

cheers,
Ben Moore
 
* Recordset is an Object so it cannot be Null. If the Query doesn't select
any Record, the Recordset is an empty Recordset.

* rs.MoveFirst will give an error as there is no first Record to move to.
Hence, before moving to first Recordset, you should check whether the
Recordset is empty or not. You can check for empty Recordset using EOF or
RecordCount.
 
Back
Top