Distinct of Null

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!
I'm having a problem with a query.

I have many many tables that I receive from my customers. I'm doing some
queries, and these queries use DISTINCT.
However some of this tables sometimes can be without registers, they have no
information.

I can't open each one to check it, so I have to use this query with Distinct
automatically.
But querying a NULL table with DISTINCT, I got a error and MsAccess closes.

What to do? Is there any way to discover automatically if the table is empty
before doing this distinct query?

Thanks everybody!
 
You could insert a simple DCount of all the records in the table, and if it
returns 0, do not run the query for that table:

If not DCount("[Field1]","[Table1]") = 0 Then DoCmd.OpenQuery "yourQueryName"
 
Back
Top