Check if table has no records

J

JKarchner

I have some code that runs when i load a form. The code used to hit a snag
when i scrolled to a new record. I have since fixed that by testing if the
record was a new record. However i found that i still an error when there
are no records in the table. Is there any way to test it other than by
running a SQL query and checking the number of records? Thank you.
 
J

JKarchner

But that still involves using an SQL query, doesn't it? I was kind of hoping
for a shorter method to it, but i guess as long as it works...
 
J

JKarchner

That is the command i ended up using and the one i figured i was going to
have to use. And it turns out that it didn't involve too many lines of code,
which i was what i had really wanted.
 
S

SusanV

Glad it helped!

JKarchner said:
That is the command i ended up using and the one i figured i was going to
have to use. And it turns out that it didn't involve too many lines of
code,
which i was what i had really wanted.
 
B

Bill

No, it doesn't:

msgbox "There are " & me.recordset.recordcount & " records in the table"

me.recordset.recordcount always evaluates to the number of records
and no other code is needed
 
S

SusanV

Ah but that assumes the OP wants to check the number of records in the table
the form is based upon - and if there were no records in that table, the
form would be unpopulated - saving the need for any query whatsoever.
;-D
 
Top