If table has no records?

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hi I would like to know how I can write the following
correctly

If me.tbl1 = norecords Then

I dont know how to say if the table contains no records
at all

Thanks

Peter
 
A SQL statement:

Select Count(*) From MyTable

You'll need a recordset object, in order to say:

If Rs.Fields(0).Value 0 Then
....
End If

Where Rs is a recordset object (Either DAO or ADO...doesn't matter)
 
You can try to use the DCount function. Something like:

If dcount("(0)","tbl1") = 0 then
' No Records
End If

Should work, as long as there is a table named tbl1 in the database. I
guess the "Proper" way to do this would be to instantiate a recordset
object, open the table, and test for EOF, but the above uses a lot less
code.

Ron W
 
Back
Top