excellis
asked on
Why am I getting "object doesn't support this property or method (438)"
I am getting the following error in my Access 2010 code:
object doesn't support this property or method (438)
Here is my code:
Public Function TestSamples() As Boolean
Pass = True
On Error GoTo Err_TestSamples
Dim Clnt As New clsClient
Clnt.Clear
LoadClientTestData (Clnt) <---Get error message on this line.
Private Sub LoadClientTestData(ByRef Clnt As clsClient) <-- This is the subroutine being called. Both sets of code are in the same module.
clsClient is a Class Module created in Access.
If I avoid the subroutine and put the code that the routine was supposed to do below this point, the class works as expected. I want to be able to put this code in a subroutine so it can be called from multiple sources.
I have searched on the error but have only found the error related to form controls.
Matt
object doesn't support this property or method (438)
Here is my code:
Public Function TestSamples() As Boolean
Pass = True
On Error GoTo Err_TestSamples
Dim Clnt As New clsClient
Clnt.Clear
LoadClientTestData (Clnt) <---Get error message on this line.
Private Sub LoadClientTestData(ByRef Clnt As clsClient) <-- This is the subroutine being called. Both sets of code are in the same module.
clsClient is a Class Module created in Access.
If I avoid the subroutine and put the code that the routine was supposed to do below this point, the class works as expected. I want to be able to put this code in a subroutine so it can be called from multiple sources.
I have searched on the error but have only found the error related to form controls.
Matt
What does the definition of LoadClientTestData look like?
ASKER
My variable is CLNT as in "Client". It is not CINT as in Convert to Integer.
Matt
Matt
ASKER
Kaufmed,
This was included in the original post:
"Private Sub LoadClientTestData(ByRef Clnt As clsClient) <-- This is the subroutine being called. Both sets of code are in the same module."
Is this what you were asking me for?
Matt
This was included in the original post:
"Private Sub LoadClientTestData(ByRef Clnt As clsClient) <-- This is the subroutine being called. Both sets of code are in the same module."
Is this what you were asking me for?
Matt
Clnt - yours
CInt - mine ....
well the Looked the same. Both above have capital L's :-)
mx
CInt - mine ....
well the Looked the same. Both above have capital L's :-)
mx
I've never tried to pass a Class object variable before.
What happens if you change
Private Sub LoadClientTestData(ByRef Clnt As clsClient)
to
Private Sub LoadClientTestData(ByRef Clnt As Object)
What happens if you change
Private Sub LoadClientTestData(ByRef Clnt As clsClient)
to
Private Sub LoadClientTestData(ByRef Clnt As Object)
ASKER
DatabaseMX,
I get the same error.
Matt
I get the same error.
Matt
Is this what you were asking me for?No. I was looking for something along the lines of:
Private Sub LoadClientTestData(ByRef Clnt As clsClient)
' Relevant code lines here
End Sub
My thought is that you have a line inside the class that is actually throwing the error, but it's being "flagged" as being on the line you experience. Just a guess, though : \
I'm not sure you can pass a Class as an argument ... are you ?
mx
mx
How about ..
LoadClientTestData (Clnt)
Private Sub LoadClientTestData(ByRef ABC As clsClient)
LoadClientTestData (Clnt)
Private Sub LoadClientTestData(ByRef ABC As clsClient)
ASKER
Kaufmed,
here is the subroutine - LoadClientTestData:
Private Sub LoadClientTestData(ByRef Clnt As clsClient)
Clnt.Clear
'Data - Default = ""
Clnt.CompanyName = "Excellis, Inc."
Clnt.Addr_1 = "30856 Groesbeck Highway"
Clnt.Addr_2 = "Suite A"
Clnt.SuiteNo = "A"
Clnt.City = "Roseville"
Clnt.State = "MI"
Clnt.Zip = "48066"
Clnt.Landline = "586.555.1212"
Clnt.MobilePhone = "586.555.1212"
Clnt.FaxNo = "888.555.1212"
Clnt.WebAddress_1 = "Excellis.com"
Clnt.WebAddress_2 = ""
Clnt.EmailAddress_1 = "info@excellis.com"
Clnt.EmailAddress_2 = ""
Clnt.CompanyTagline = "Your data matters to us along with a check."
Clnt.Personalization_1 = ""
Clnt.Personalization_2 = ""
Clnt.CompanyAlias = ""
End Sub
DatabaseMX:
I thought all Objects were Classes. So I am assuming that a Class Module could be passed as a parameter.
Matt
here is the subroutine - LoadClientTestData:
Private Sub LoadClientTestData(ByRef Clnt As clsClient)
Clnt.Clear
'Data - Default = ""
Clnt.CompanyName = "Excellis, Inc."
Clnt.Addr_1 = "30856 Groesbeck Highway"
Clnt.Addr_2 = "Suite A"
Clnt.SuiteNo = "A"
Clnt.City = "Roseville"
Clnt.State = "MI"
Clnt.Zip = "48066"
Clnt.Landline = "586.555.1212"
Clnt.MobilePhone = "586.555.1212"
Clnt.FaxNo = "888.555.1212"
Clnt.WebAddress_1 = "Excellis.com"
Clnt.WebAddress_2 = ""
Clnt.EmailAddress_1 = "info@excellis.com"
Clnt.EmailAddress_2 = ""
Clnt.CompanyTagline = "Your data matters to us along with a check."
Clnt.Personalization_1 = ""
Clnt.Personalization_2 = ""
Clnt.CompanyAlias = ""
End Sub
DatabaseMX:
I thought all Objects were Classes. So I am assuming that a Class Module could be passed as a parameter.
Matt
Where did you assign all of the properties (fields) of the class. You have to define these somewhere, otherwise you will get an error on Clint.CompanyName
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
HainKurt,
Your solution worked. I don't know why but it did.
Change LoadClientTestData (Clnt)
-->
LoadClientTestData Clnt
Thank you,
Matt
Your solution worked. I don't know why but it did.
Change LoadClientTestData (Clnt)
-->
LoadClientTestData Clnt
Thank you,
Matt
ASKER
The solution works but I do not understand why.
<<My variable is CLNT as in "Client". It is not CINT as in Convert to Integer.>>
That's going to be really confusing for anyone looking at this code now or in the future. I would change it to something else and avoid using that.
Jim.
it is a sub, not function, so it does not require "(..)"
excellis: Try this:
LoadClientTestData (Clnt)
Private Function LoadClientTestData(ByRef Clnt As clsClient)
' code
End Function
LoadClientTestData (Clnt)
Private Function LoadClientTestData(ByRef Clnt As clsClient)
' code
End Function
it is a sub, not function, so it does not require "(..)"I agree with HainKurt's assessment, but alternatively you could do:
Call LoadClientTestData (Clnt)
if you were set on using parentheses : )
Try using a different variable name.
Dim CXlnt As New clsClient
CXlnt.Clear
LoadClientTestData (CXlnt)
mx