Home All Groups Group Topic Archive Search About

check if table is empty

Author
27 Dec 2006 3:59 PM
andrewbda@gmail.com
How do I check if a table is empty in access?

I need to run different VB depending on if a certain table is empty or
not.

Thanks!

Author
27 Dec 2006 4:16 PM
Rad [Visual C# MVP]
On 27 Dec 2006 07:59:01 -0800, andrew***@gmail.com wrote:

> How do I check if a table is empty in access?
>
> I need to run different VB depending on if a certain table is empty or
> not.
>
> Thanks!

You could do a select count on the table to determine the number of records
....

Author
27 Dec 2006 4:16 PM
vbnetdev
Load the table in your dataadapter and then

If dstest.Tables(0).Rows.Count = -1 Then
MsgBox("EMPTY")
End If

<andrew***@gmail.com> wrote in message
Show quoteHide quote
news:1167235141.819331.186810@79g2000cws.googlegroups.com...
> How do I check if a table is empty in access?
>
> I need to run different VB depending on if a certain table is empty or
> not.
>
> Thanks!
>
Author
27 Dec 2006 4:18 PM
Martin Horn
Hi,

you could try either

dim dt as datatable

if dt.columns.count=0 then msgbox("Table has no columns")

or

dt.rows.count=0 then msgbox ("Table has no rows.")

depending on your meaning of 'empty'

HTH

Martin

<andrew***@gmail.com> wrote in message
Show quoteHide quote
news:1167235141.819331.186810@79g2000cws.googlegroups.com...
> How do I check if a table is empty in access?
>
> I need to run different VB depending on if a certain table is empty or
> not.
>
> Thanks!
>
Author
27 Dec 2006 4:18 PM
Tim Patrick
Use the COUNT SQL function to return a count of rows. If the result is zero,
the table is empty.

   SELECT COUNT(*) FROM Table1

-----
Tim Patrick - www.timaki.com
Start-to-Finish Visual Basic 2005

Show quoteHide quote
> How do I check if a table is empty in access?
>
> I need to run different VB depending on if a certain table is empty or
> not.
>
> Thanks!
>