Question : loop through all linked tables

Hi

I want to loop through all linked tables in access, outputting to excel the TableName for all tables where their recordcounts are greater than 0

Thanks

Answer : loop through all linked tables

Here you go...

JimD.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
 Sub GetRecordCounts()
 
 Dim db As DAO.Database
 Dim objtblDef As DAO.TableDef
 Dim varCount As Variant
 
 Set db = CurrentDb()
 
 For Each objtblDef In db.TableDefs
    If objtblDef.Connect <> "" Then
      varCount = DCount("*", objtblDef.Name)
      If varCount > 0 Then
         Debug.Print objtblDef.Name, varCount
      End If
    End If
 Next
 
  Set objtblDef = Nothing
  
  Set db = Nothing
 
 End Sub
Random Solutions  
 
programming4us programming4us