M
Matt Williamson
I have about 100 Access MDB's that have a reference to a table in
multiple queries that I need to replace with a new table. I've written the
following code to do so, but it keeps giving me the error about dependency
info not being updated. I thought adding 'oApp.SetOption "Track Name
AutoCorrect Info", 1' should turn it on for each instance of Access that I'm
opening. Do I need to save the database first?
Public Sub FindQueryDependsInMDBs()
Dim oApp As Access.Application
Dim oAccTable As AccessObject
Dim oAccQuery As AccessObject
Dim sPath As String, sMDB As String
sPath = GetPath(CurrentDb.Name)
sMDB = Dir$(sPath & "\*.mdb")
Do While sMDB <> ""
If sPath & sMDB <> CurrentDb.Name Then
' Debug.Print sMDB & vbCrLf & String(20, "-") & vbCrLf
Set oApp = New Access.Application
oApp.OpenCurrentDatabase (sPath & "\" & sMDB)
oApp.SetOption "Track Name AutoCorrect Info", True 'tried 1 here
as well
For Each oAccTable In oApp.CurrentData.AllTables
If Left(oAccTable.Name, 4) <> "MSys" Then
If InStr(oAccTable.Name, "VALUE_WITH_CLASS") <> 0 Then
For Each oAccQuery In oApp.CurrentData.AllQueries
If oAccQuery.IsDependentUpon(acTable,
"dbo_VALUE_WITH_CLASS_VT_DAILY") Then
Debug.Print oAccQuery.Name & "is dependent upon
dbo_VALUE_WITH_CLASS_VT_DAILY"
End If
If oAccQuery.IsDependentUpon(acTable,
"dbo_VALUE_WITH_CLASS_VT_MONTHE") Then
Debug.Print oAccQuery.Name & "is dependent upon
dbo_VALUE_WITH_CLASS_VT_MONTHE"
End If
Next oAccQuery
End If
End If
Next oAccTable
oApp.CloseCurrentDatabase
oApp.Quit acQuitSaveNone
End If
sMDB = Dir$
Loop
End Sub
TIA
Matt
multiple queries that I need to replace with a new table. I've written the
following code to do so, but it keeps giving me the error about dependency
info not being updated. I thought adding 'oApp.SetOption "Track Name
AutoCorrect Info", 1' should turn it on for each instance of Access that I'm
opening. Do I need to save the database first?
Public Sub FindQueryDependsInMDBs()
Dim oApp As Access.Application
Dim oAccTable As AccessObject
Dim oAccQuery As AccessObject
Dim sPath As String, sMDB As String
sPath = GetPath(CurrentDb.Name)
sMDB = Dir$(sPath & "\*.mdb")
Do While sMDB <> ""
If sPath & sMDB <> CurrentDb.Name Then
' Debug.Print sMDB & vbCrLf & String(20, "-") & vbCrLf
Set oApp = New Access.Application
oApp.OpenCurrentDatabase (sPath & "\" & sMDB)
oApp.SetOption "Track Name AutoCorrect Info", True 'tried 1 here
as well
For Each oAccTable In oApp.CurrentData.AllTables
If Left(oAccTable.Name, 4) <> "MSys" Then
If InStr(oAccTable.Name, "VALUE_WITH_CLASS") <> 0 Then
For Each oAccQuery In oApp.CurrentData.AllQueries
If oAccQuery.IsDependentUpon(acTable,
"dbo_VALUE_WITH_CLASS_VT_DAILY") Then
Debug.Print oAccQuery.Name & "is dependent upon
dbo_VALUE_WITH_CLASS_VT_DAILY"
End If
If oAccQuery.IsDependentUpon(acTable,
"dbo_VALUE_WITH_CLASS_VT_MONTHE") Then
Debug.Print oAccQuery.Name & "is dependent upon
dbo_VALUE_WITH_CLASS_VT_MONTHE"
End If
Next oAccQuery
End If
End If
Next oAccTable
oApp.CloseCurrentDatabase
oApp.Quit acQuitSaveNone
End If
sMDB = Dir$
Loop
End Sub
TIA
Matt