Check if any records in the table

B

Bertie

Hi
What's the most straightforward approach to check for records in a table?

Basically if the table is empty I want to run a particular action, if it is
not empty then I want to run another action.

Many thanks
 
A

Allen Browne

Use DLookup() on the primary key of the table.
If it returns Null, there's no records.

Example:
If IsNull(DLookup("ID", "Table1")) Then ...
 
F

fredg

Hi
What's the most straightforward approach to check for records in a table?

Basically if the table is empty I want to run a particular action, if it is
not empty then I want to run another action.

Many thanks

If DCount("*","TableName")>0 Then
' Has records
Else
' No records
End If
 
Top