D
Duck
I am new to VBA and am studying from a pretty good book. However I am
puzzled by an error I get when trying to run a piece of code taken
almost directly from the book. The code is supposed to fetch the
dependencies of given database objects and print them to the immediate
window, however when I run the code in the immediate window by issuing
the command: ShowDependencies(acForm, frmRecallDateSelection), I get
the error: Compile Error: Expected:=
Here is the code:
Public Sub ShowDependencies(intType As AcObjectType, strObject As
String)
Dim AO As AccessObject
Dim AO2 As AccessObject
Dim DI As DependencyInfo
On Error GoTo HandleErr
Select Case intType
Case acTable
Set AO = CurrentData.AllTables(strObject)
Debug.Print "Table: ";
Case acQuery
Set AO = CurrentData.AllQueries(strObject)
Debug.Print "Query: ";
Case acForm
Set AO = CurrentProject.AllForms(strObject)
Debug.Print "Form: ";
Case acReport
Set AO = CurrentProject.AllReports(strObject)
Debug.Print "Report: ";
Case Else
Debug.Print "Object " & strObject & " Not Covered"
Exit Sub
End Select
Debug.Print strObject
'Get Dependency Information
Set DI = AO.GetDependencyInfo()
'Print Results
If (DI.Dependencies.Count = 0) Then
Debug.Print "Object " & AO & " has no dependencies"
Else
Debug.Print "Object " & AO & " depends on these other
objects:"
For Each AO2 In DI.Dependencies
Select Case AO2.Type
Case acTable
Debug.Print " Table: ";
Case acQuery
Debug.Print " Query: ";
Case acForm
Debug.Print " Form: ";
Case acReport
Debug.Print " Report: ";
Case Else
Debug.Print " I dont know??"
End Select
Debug.Print AO2.Name
Next AO2
End If
If (DI.Dependants.Count = 0) Then
Debug.Print "Object " & AO & " has no dependants"
Else
Debug.Print "Object " & AO & " depends on these other
objects:"
For Each AO2 In DI.Dependants
Select Case AO2.Type
Case acTable
Debug.Print " Table: ";
Case acQuery
Debug.Print " Query: ";
Case acForm
Debug.Print " Form: ";
Case acReport
Debug.Print " Report: ";
Case Else
Debug.Print " Unidentified Object"
End Select
Debug.Print AO2
Next AO2
End If
ExitHere:
Exit Sub
HandleErr:
Debug.Print "Error " & Err.Number & ":" & Err.Description,
vbCritical
Resume ExitHere
End Sub
puzzled by an error I get when trying to run a piece of code taken
almost directly from the book. The code is supposed to fetch the
dependencies of given database objects and print them to the immediate
window, however when I run the code in the immediate window by issuing
the command: ShowDependencies(acForm, frmRecallDateSelection), I get
the error: Compile Error: Expected:=
Here is the code:
Public Sub ShowDependencies(intType As AcObjectType, strObject As
String)
Dim AO As AccessObject
Dim AO2 As AccessObject
Dim DI As DependencyInfo
On Error GoTo HandleErr
Select Case intType
Case acTable
Set AO = CurrentData.AllTables(strObject)
Debug.Print "Table: ";
Case acQuery
Set AO = CurrentData.AllQueries(strObject)
Debug.Print "Query: ";
Case acForm
Set AO = CurrentProject.AllForms(strObject)
Debug.Print "Form: ";
Case acReport
Set AO = CurrentProject.AllReports(strObject)
Debug.Print "Report: ";
Case Else
Debug.Print "Object " & strObject & " Not Covered"
Exit Sub
End Select
Debug.Print strObject
'Get Dependency Information
Set DI = AO.GetDependencyInfo()
'Print Results
If (DI.Dependencies.Count = 0) Then
Debug.Print "Object " & AO & " has no dependencies"
Else
Debug.Print "Object " & AO & " depends on these other
objects:"
For Each AO2 In DI.Dependencies
Select Case AO2.Type
Case acTable
Debug.Print " Table: ";
Case acQuery
Debug.Print " Query: ";
Case acForm
Debug.Print " Form: ";
Case acReport
Debug.Print " Report: ";
Case Else
Debug.Print " I dont know??"
End Select
Debug.Print AO2.Name
Next AO2
End If
If (DI.Dependants.Count = 0) Then
Debug.Print "Object " & AO & " has no dependants"
Else
Debug.Print "Object " & AO & " depends on these other
objects:"
For Each AO2 In DI.Dependants
Select Case AO2.Type
Case acTable
Debug.Print " Table: ";
Case acQuery
Debug.Print " Query: ";
Case acForm
Debug.Print " Form: ";
Case acReport
Debug.Print " Report: ";
Case Else
Debug.Print " Unidentified Object"
End Select
Debug.Print AO2
Next AO2
End If
ExitHere:
Exit Sub
HandleErr:
Debug.Print "Error " & Err.Number & ":" & Err.Description,
vbCritical
Resume ExitHere
End Sub