Transentient
Registered User.
- Local time
- Today, 14:58
- Joined
- Sep 25, 2007
- Messages
- 31
I have been using the attached code within an Access 97 database to count different types of tables within the application. On calling the function a variable is passed telling the code what table type to count, i.e. ADD for Address Tables, CON for contacts tables.
It has always worked find in Access 97, however on upgrading the database to 2007, the code doe'nt work, seems to have problems with the Tabledefs funcrtion and the Left function.
Can anyone help, is there a different way of doing this with Access 2007?
Thanx in advance
Public Function Count(CountCriteria As String) As Integer
Dim i As Integer '
Dim db As Database '
Dim System_Filters '
Dim Current_TableName 'Declare Used Variables
Dim Hidden_Filters '
Dim Other_Filters '
Set db = DBEngine(0)(0) 'Define Global Variables
Count = 0 ' ' '
db.TableDefs.Refresh 'Refresh Table Objects List ' '
For i = 1 To db.TableDefs.Count 'Define & Excecute Loop 'Current_TableName = db.TableDefs(i) '.Name ' '
System_Filters = Left(Current_TableName, 4) 'Define Local Variables
Hidden_Filters = Left(Current_TableName, 1) 'For Filters
Other_Filters = Left(Current_TableName, 3) '
'Filter to Remove System Objects & User Defined Items
If System_Filters <> "MSys" And System_Filters <> "USys" And _
Hidden_Filters <> "~" And Other_Filters = CountCriteria Then
Count = Count + 1 'Update Variable
End If 'End Filter
Next i 'Loop Back
End Function
It has always worked find in Access 97, however on upgrading the database to 2007, the code doe'nt work, seems to have problems with the Tabledefs funcrtion and the Left function.
Can anyone help, is there a different way of doing this with Access 2007?
Thanx in advance
Public Function Count(CountCriteria As String) As Integer
Dim i As Integer '
Dim db As Database '
Dim System_Filters '
Dim Current_TableName 'Declare Used Variables
Dim Hidden_Filters '
Dim Other_Filters '
Set db = DBEngine(0)(0) 'Define Global Variables
Count = 0 ' ' '
db.TableDefs.Refresh 'Refresh Table Objects List ' '
For i = 1 To db.TableDefs.Count 'Define & Excecute Loop 'Current_TableName = db.TableDefs(i) '.Name ' '
System_Filters = Left(Current_TableName, 4) 'Define Local Variables
Hidden_Filters = Left(Current_TableName, 1) 'For Filters
Other_Filters = Left(Current_TableName, 3) '
'Filter to Remove System Objects & User Defined Items
If System_Filters <> "MSys" And System_Filters <> "USys" And _
Hidden_Filters <> "~" And Other_Filters = CountCriteria Then
Count = Count + 1 'Update Variable
End If 'End Filter
Next i 'Loop Back
End Function