Does any body have any sample code to loop through a set of Access tables within a certain directory? I need to be able to loop through all the access tables in the given directory and make changes to certain fields within each table.
Thanks
Printable View
Does any body have any sample code to loop through a set of Access tables within a certain directory? I need to be able to loop through all the access tables in the given directory and make changes to certain fields within each table.
Thanks
all access tables inside a database are stored withÃÂ*n a single MDB file.
Thus, after you open it using Opendatabase you can iterate over the tabledefs collection to access all tables in the database.
First, tables are in a database, databeses are in a dir.
If you got multiple tables in one database, use the tabledef to go through them, if you got more databases in one directory, use the dir command.
myDbFile = dir("path","*.mdb")
do while myDbFile <> ""
data1.databasename = myDbFile
data1.recordsource = "name_of_tabel"
data1.recordset.refresh
data1.recordset.movefirst
do while not(data1.recordset.eof)
with data1.recordset
.edit
.fields!field_to_modify = "new_value"
.update
.movenext
end with
loop
'check if there are anymore databases to process in the directory
myDbFile = dir
loop
Tom Cannaerts
[email protected]
Wow!!! Thanks a mill. guys!!!! I'll try it out....