1

I have a set of owners, who each have their own set of opportunities.

I have two class modules, ClmOpportunity which has a bunch of properties, and ClmOwner which has a single name property and a Collection storing ClmOpportunity Objects:

Public name As Variant
Private opps As New collection

Public Function addOpportunity(opp As ClmOpportunity)

    opp.ID = opps.Count + 1
    opps.Add opp, opps.Count + 1

End Function

These owner objects are also being stored in a collection in my main module. When I try to use the function addOpportunity as shown below:

Dim item As New ClmOpportunity

item.name = "test"

owners.item(overallOwner).addOpportunity (item)

I get the error:

"object doesn't support this property or method"

I am quite new to VBA and I don't understand why this is, I am passing in a ClmOpportunity, so it should be fine right?

Any help would be greatly appreciated!

1 Answer 1

6

You don't use parentheses if there's no return value...

owners.item(overallOwner).addOpportunity item

...then you'll get a "type mismatch" error because a collection expects a string value as a key, so you'll need to adjust your addOpportunity function (which should probably be a Sub if you don't intend adding a returned value)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.