Check out the DCount function (in Help file). It's a quick way to see if you
have any records in a table or query:
If DCount("*", "TableOrQueryName") = 0 Then
MsgBox "There are no records in the table or query."
Else
' do something in your code
End If
You also can filter the function using an SQL "WHERE" statement without the
"WHERE". For example, if you wanted to know if any records exist that have a
value of 12 in the FieldName field:
If DCount("*", "TableOrQueryName", "[FieldName] = 12") = 0 Then
MsgBox "There are no records in the table or query that match your
criteria."
Else
' do something in your code
End If
--
Ken Snell
<MS ACCESS MVP>
Dave F said:
In my module I need to perform some action if records exist in a table.
I'm guessing I would use an SQL statement, but what is the syntax to
determine the record count for a table and test the variable for a value?
Thanks,
Dave F.