PC Review


Reply
Thread Tools Rate Thread

How to determine if table contains no records?

 
 
=?Utf-8?B?UmljaGFyZEE=?=
Guest
Posts: n/a
 
      21st Jun 2004
Hello,

I use the following code to determine if tblTable exists before using it later. But the code is not enough because the table could be empty. How do I check if the tblTable has no data? Or is empty? Contains no records? Thanks,

RichardA

Dim dbs As Database
Dim tdf As TableDef
Dim blnTableExists As Boolean

'Determine if a table exists.
blnTblExists = False
Set dbs = CurrentDb()
For Each tdf In dbs.TableDefs
If tdf.Name = "tblTable" Then blnTableExists = True
Next tdf

If (blnTableExists = False) Then 'Do not access tblTable
GoTo 10
End If

 
Reply With Quote
 
 
 
 
=?Utf-8?B?bWVkaWFsaW50?=
Guest
Posts: n/a
 
      21st Jun 2004
Use RecordCount, like:

currentdb.TableDefs("AllData").RecordCount

If = 0 then it is empty.

"RichardA" wrote:

> Hello,
>
> I use the following code to determine if tblTable exists before using it later. But the code is not enough because the table could be empty. How do I check if the tblTable has no data? Or is empty? Contains no records? Thanks,
>
> RichardA
>
> Dim dbs As Database
> Dim tdf As TableDef
> Dim blnTableExists As Boolean
>
> 'Determine if a table exists.
> blnTblExists = False
> Set dbs = CurrentDb()
> For Each tdf In dbs.TableDefs
> If tdf.Name = "tblTable" Then blnTableExists = True
> Next tdf
>
> If (blnTableExists = False) Then 'Do not access tblTable
> GoTo 10
> End If
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine number of records in table laavista Microsoft Access 4 9th Apr 2009 12:40 AM
in macro how to determine a table is empty or number of records=0 =?Utf-8?B?Y2hvaWdhcnk=?= Microsoft Access Macros 2 8th May 2007 05:11 AM
Copy Records from Access Database table(more than 5 lakh records in this table) to Excel Sheet divya Microsoft Excel Programming 1 26th Oct 2006 12:12 PM
How to determine how many records are in subform?? Domac Microsoft Access Forms 2 22nd May 2006 02:45 PM
Determine if records qualified Chris Microsoft Access Form Coding 4 1st Nov 2004 11:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:52 PM.