Puzzled by Compile Error: Expected:=

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
 
S

Stefan Hoffmann

hi,
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:=
You have to use either

Call Procedure(Parameters)

or

Procedure Parameters



mfG
--> stefan <--
 
D

Duck

hi,


You have to use either

   Call Procedure(Parameters)

or

   Procedure Parameters

mfG
--> stefan <--

Thanks Stefan, your suggestion was a step in the right direction, but
now I'm getting the error: Error 438:Object doesn't support this
property or method 16

Any idea why this is happening?
 
D

Dirk Goldgar

Duck said:
Thanks Stefan, your suggestion was a step in the right direction, but
now I'm getting the error: Error 438:Object doesn't support this
property or method 16

Any idea why this is happening?

Are you passing the form name as a string, as the procedure requires? It
looks like you're passing the form itself. Instead of this:

ShowDependencies acForm, frmRecallDateSelection 'WRONG

you should say this:

ShowDependencies acForm, "frmRecallDateSelection"
 
D

Duck

Are you passing the form name as a string, as the procedure requires?  It
looks like you're passing the form itself.  Instead of this:

    ShowDependencies acForm, frmRecallDateSelection    'WRONG

you should say this:

    ShowDependencies acForm, "frmRecallDateSelection"

--
Dirk Goldgar, MS Access MVPwww.datagnostics.com

(please reply to the newsgroup)- Hide quoted text -

- Show quoted text -

I am indeed passing the form name as a string:

ShowDependencies acForm, "frmRecallDateSelection"

I have also tried with different objects ie:

ShowDependencies acTable, "tblCustomer

But I get the same error :(
 
D

Dirk Goldgar

Duck said:
I am indeed passing the form name as a string:

ShowDependencies acForm, "frmRecallDateSelection"

I have also tried with different objects ie:

ShowDependencies acTable, "tblCustomer

But I get the same error :(

So what line is giving the error? And what version of Access are you using?
I'm not sure, but I don't think the GetDependencyInfo method was available
before Access 2003.
 
D

Duck

So what line is giving the error?  And what version of Access are you using?
I'm not sure, but I don't think the GetDependencyInfo method was available
before Access 2003.

I have stepped through the procedure both with objects that I know
have dependencies and also with objects that I know do not have
dependencies, and the code errors out at the same relative place. It
errors at the line:
Debug.Print "Object " & AO & " has no dependants" or
Debug.Print "Object " & AO & " depends on these other objects" of
course depending on whether the object in question has any
dependencies or not.

I am using Access 2003 and WindowsXP Professional
 
D

Dirk Goldgar

Duck said:
I have stepped through the procedure both with objects that I know have
dependencies and also with objects that I know do not have dependencies,
and the code errors out at the same relative place. It errors at the
line:
Debug.Print "Object " & AO & " has no dependants" or
Debug.Print "Object " & AO & " depends on these other objects" of
course depending on whether the object in question has any
dependencies or not.


You have to refer to the Name property of the AO object:

Debug.Print "Object " & AO.Name & " has no dependants"
Debug.Print "Object " & AO.Name & " depends on these other objects"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top