Is the following code correct?

zhuanyi

Registered User.
Local time
Today, 03:20
Joined
Apr 24, 2007
Messages
66
Hello,
I wrote the following code in one of the programs:
Code:
'first, define necessary variables
Dim db As Database
Dim tableCounter As Integer
Dim newtablename As String
newtablename = "AppendAllFields"

Set db = CurrentDb
Dim counter As Integer

counter = 1
'loop around for tables
Do While InStr(1, Left(db.TableDefs(counter).Name, 3), "Inf") = 0
Whenever I tried to run it, the program kept saying:
Item not found in this collection, and the value of the counter is set to 14 although I only have 10 tables, with the first one containing Inf in the name.
Could anyone please help? Thanks!
 
Your count is off becasue there are hidden system tables. I would use a For...Each loop to loop through the table collection.
 

Users who are viewing this thread

Back
Top Bottom