Object doesnt support this property or method (1 Viewer)

dbarasch

New member
Local time
Yesterday, 21:10
Joined
May 8, 2010
Messages
6
I am having a problem passing a object as a parameter to my AddCreditCardTransaction Sub within my CreditCardBatch class.

In my CreditCardBatch class, I have this sub procedure

Public Sub AddCreditCardTransaction(CreditCardTransaction As clsCreditCardTransaction)
MsgBox (CreditCardTransaction.CustomerName)
End Sub

In a module, I have the following code:

Public Sub test()

Dim obatch As New clsCreditCardBatch
Dim oCC As New clsCreditCardTransaction


obatch.AddCreditCardTransaction (oCC) << I get an error message here

End Sub

I get an error stating that the object doesnt support this property or method.

Any suggestions why I am getting this error. Can I not pass an object to a sub procedure in another class, and use the Credit Card object properties in the CreditCardBatchClass?

 

LPurvis

AWF VIP
Local time
Today, 05:10
Joined
Jun 16, 2008
Messages
1,269
Hi

Welcome to these here forums.

You have:
obatch.AddCreditCardTransaction (oCC)

In doing so you're attempting to coerce the object you've just created into a scalar type ByVal (by wrapping the object in brackets).
Since it's an object - you need to pass it as a reference to the same object.
i.e. it should just be:
obatch.AddCreditCardTransaction oCC

You'd get away with:
Call obatch.AddCreditCardTransaction (oCC)

But I think that's obscuring the problem for you.

Cheers.
 

ChrisO

Registered User.
Local time
Today, 14:10
Joined
Apr 30, 2003
Messages
3,202
Not meant as a correction of any sort…

Call obatch.AddCreditCardTransaction (oCC)

will show in the editor as

Call obatch.AddCreditCardTransaction(oCC)

note the missing space between AddCreditCardTransaction and (oCC)

Code:
Call obatch.AddCreditCardTransaction(oCC)
     obatch.AddCreditCardTransaction (oCC)

So when we see a space in that position it’s a good sign that there is a forced coercion going on.
 

LPurvis

AWF VIP
Local time
Today, 05:10
Joined
Jun 16, 2008
Messages
1,269
A worthwhile point. A visual hint that something is amiss.
 

Users who are viewing this thread

Top Bottom