expression to check if table is empty

J

Jason Morin

Hello, using Access 2002/WinXP.
I have button on a form that allows the user to move to
the next form, but the button runs a macro that checks
several things (such as checking for the existence of a
file on the user's PC) before a allowing the user to move
on. If the condition in the macro is not met, I just use
StopMacro and throw up a msgbox with a warning.

Condition Action
Len(Dir("C:\...))<2 Msgbox
.... StopMacro

The one check I'm struggling with is how to check a table
to see if it is empty (no records). Seems simple. I tried:

Condition Action
Sum([region1]![sales])=0 Msgbox
.... StopMacro

But I get the error: "The object doesn't contain the
Automation object "region1".

Any suggestions? Thanks for taking the time to read this.
Jason
 
K

Ken Snell

Use the DCount function:

DCount("*", "TableName") = 0

When above is true, the table has no records.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top