Counting the number of tables (1 Viewer)

D

Dealerz

Guest
hi,

Im pretty sure this is possible in access as ive found some examples but have been unable to incorporate them into my module.

Basically i need to set strNextValue as the number of tables in my access DB. Does anyone know of a function which counts the tables?

thanks.
 

Travis

Registered User.
Local time
Yesterday, 20:36
Joined
Dec 17, 1999
Messages
1,332
Code:
Public Function TableCount() As Integer
    Dim db As DAO.Database, tdf As DAO.TableDef, fld As DAO.Field
    Dim iCount As Integer
    
    Set db = CurrentDb
    
    For Each tdf In db.TableDefs
        If tdf.Attributes = 0 Then iCount = iCount + 1
    Next tdf
    TableCount = iCount

End Function
 
D

Dealerz

Guest
thanks, but i get the compile error "user-defined type not defined" with the section "db As DAO.Database" any ideas? :)

thanks
 

WayneRyan

AWF VIP
Local time
Today, 04:36
Joined
Nov 19, 2002
Messages
7,122
Dealerz,

This is a reference problem.

In design view for your code,
Select Tools --> References
Scroll down and click on the DAO reference.

You should be OK,

Wayne
 

Users who are viewing this thread

Top Bottom