Solved

Why am I getting "object doesn't support this property or method (438)"

Posted on 2011-09-07
19
502 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:excellis
  • 6
  • 6
  • 3
  • +3
19 Comments
 
LVL 75
ID: 36497523
Clnt is a function in Access   CInt()

Try using a different variable name.

    Dim CXlnt As New clsClient
    CXlnt.Clear
    LoadClientTestData (CXlnt)

mx
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36497562
What does the definition of LoadClientTestData look like?
0
 

Author Comment

by:excellis
ID: 36497568
My variable is CLNT as in "Client".  It is not CINT as in Convert to Integer.

Matt
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:excellis
ID: 36497587
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
0
 
LVL 75
ID: 36497593
Clnt - yours
CInt - mine ....

well the Looked the same.  Both above have capital L's  :-)

mx

0
 
LVL 75
ID: 36497624
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)  
0
 

Author Comment

by:excellis
ID: 36497660
DatabaseMX,

I get the same error.

Matt
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36497663
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

Open in new window


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  : \
0
 
LVL 75
ID: 36497664
I'm not sure you can pass a Class as an argument ... are you ?

mx
0
 
LVL 75
ID: 36497703
How about ..


    LoadClientTestData (Clnt)

Private Sub LoadClientTestData(ByRef ABC As clsClient)  
0
 

Author Comment

by:excellis
ID: 36497721
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
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 36497766
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
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 36497770
did you try

LoadClientTestData (Clnt)
-->
LoadClientTestData Clnt
0
 

Author Comment

by:excellis
ID: 36497823
HainKurt,

Your solution worked.  I don't know why but it did.

Change LoadClientTestData (Clnt)
-->
LoadClientTestData Clnt

Thank you,
Matt
0
 

Author Closing Comment

by:excellis
ID: 36497826
The solution works but I do not understand why.
0
 
LVL 57
ID: 36497861

<<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.
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36497970
it is a sub, not function, so it does not require "(..)"
0
 
LVL 75
ID: 36497990
excellis:  Try this:

LoadClientTestData (Clnt)  

Private Function LoadClientTestData(ByRef Clnt As clsClient)

' code

End Function
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36498251
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)

Open in new window


if you were set on using parentheses  : )
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access 2016 5 53
Any Way to Print an Import Spec? 3 29
Create a EXCEL FIle from Access Procedure 1 12
aggregate query? 3 29
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question