Viewing Non-Empty Tables

FireStrike

Registered User.
Local time
Today, 02:24
Joined
Jul 14, 2006
Messages
69
Hello,

I have a table called tbl2A. I want to open this table as long as there is some data in it. I have the code below that works very well.

Code:
    strSQL = "select * from tbl2A"
    Set rcd = CurrentDb.OpenRecordset(strSQL)
    rcd.MoveFirst
    If rcd.RecordCount > 0 Then
        DoCmd.OpenTable "tbl2A"
    End If

The question I have is if there is a cleaner, more elegant way of doing this. I actually have a number of tables, and this ends up being alot of code for each of them.

Thank you in advance.
 
Well another option would be using DCount, nothing much different of what you are doing to be honest.

Code:
If DCount("some_Column_in_tbl2A","tbl2A") > 0 Then
        DoCmd.OpenTable "tbl2A"
End If
 
Thank you worked perfectly. Makes my code look quite a bit nicer.
 

Users who are viewing this thread

Back
Top Bottom