Viewing Non-Empty Tables (1 Viewer)

FireStrike

Registered User.
Local time
Yesterday, 19:12
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.
 

pr2-eugin

Super Moderator
Local time
Today, 00:12
Joined
Nov 30, 2011
Messages
8,494
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
 

FireStrike

Registered User.
Local time
Yesterday, 19:12
Joined
Jul 14, 2006
Messages
69
Thank you worked perfectly. Makes my code look quite a bit nicer.
 

Users who are viewing this thread

Top Bottom