Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expected function or variable error.

Status
Not open for further replies.

rlusk49

Technical User
Nov 7, 2002
18
CA
Can anyone tell me why the following code returns the following error: "Compile error: Expected function or variable". It hangs on GetPersonProfile. The object
mobjPerson has been created and set on Form Load.

Private Sub DisplayFamily()

Dim arrPersons As Variant

arrPersons = mobjPerson.GetPersonProfile(mlngPersonID)
 
Hi there

in your array declaration shouldn't it be

Dim arrPersons() As Variant .. ?

Hope this helps

Transcend
 
Thanks for the tip, but still the same error.
 
You have the following assignment statement.
Code:
arrPersons = mobjPerson.GetPersonProfile(mlngPersonID)
For this to make sense, the mobjPerson.GetPersonProfile(mlngPersonID) must resolve to some value, and that value will then be assigned to your arrPersons variant variable.

Based on the shown syntax, the system is expecting mobjPerson to be some type of object, with GetPersonProfile as a method of that object, which accepts mlngPersonID as a parameter. And because this statement is used as the object of an assignment statment, the system expects this method (function) to return a value.

One of these conditions is not correct, thus the system then returns the error "Compile error: Expected function or variable"
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Hello CajunCenturion

I fully understand everything you said. The object mobjPerson has been created, set on FormLoad and set to nothing on FormUnload. I have a class CPerson which has a method called GetPersonProfile and a class CPersonDB with a method GetPersonProfileDB as shown below. Everything appears to be as you stated. What is weird is that the IntelliSense brings everything up as I type. But still get the error.

Public Sub GetPersonProfile(ByVal argPersonID As Long)

Dim arrPersons As Variant
Dim objPersonDB As CPersonDB

Set objPersonDB = New CPersonDB
arrPersons = objPersonDB.GetPersonProfileDB(argPersonID)
Set objPersonDB = Nothing

PersonID = arrPersons(0, 0)
FirstName = arrPersons(2, 0)
MiddleName = arrPersons(3, 0) & "" 'Not required
LastName = arrPersons(4, 0)

End Sub
___________________________________________________________

Public Function GetPersonProfileDB(ByVal argPersonID As Long) As Variant

mstrSQL = "Select * from tblPersons Where PersonID = " & argPersonID

GetPersonProfileDB = mobjDataAccess.Retrieve(mstrSQL)

End Function
 
Hi again

Got it to work with the following:

mobjPerson.GetPersonProfile (mlngPersonID)

txtFather.Text = mobjPerson.Father
txtMother.Text = mobjPerson.Mother
strFamilyNumber = mobjPerson.FamilyNumber

Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top