Sub SaveAs()
Dim appAccess As Application
Dim tdf As TableDef
Dim strNewDB As String
strNewDB = "path\to\your_fixed_name.mdb" 'path and filename of the new database
If Dir(strNewDB) <> "" Then
'delete new database if already exists
Kill strNewDB
End If
'open new Access app and create new database
Set appAccess = CreateObject("Access.Application")
appAccess.NewCurrentDatabase strNewDB
'close app
appAccess.CloseCurrentDatabase
Set appAccess = Nothing
'loop through all tables in this database and insert into the new database
For Each tdf In CurrentDb.TableDefs
If tdf.Attributes = 0 Then 'skip system tables
CurrentDb.Execute ("SELECT * INTO " & tdf.Name & " IN """ & strNewDB & """ FROM " & tdf.Name & ";")
End If
Next tdf
End Sub
|