Assigning Address To A Variable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I am trying to assign a variable the address of a collection object. I
want to use one several possible collections in an argument list. When I try
to assign the variable the address of the collection I get a compile error,
“Argument not Optionalâ€

Here a code sample:

Private Function foo (level As GetRecipeLevel, …) As Boolean

Dim PKeyAddr As Collection

With myCollectionList

Select Case level

Case MenuCategoryLevel
PKeyAddr = .MenuCategory ' Collection Object of Menu Category
Names

Case RecipeTypeLevel
PKeyAddr = .RecipeType ' Collection Object of Recipe Type
Names

Case RecipeCategoryLevel
PKeyAddr = .RecipeCategory ' Collection Object of Recipe
Category Names

Case RecipeNameLevel
PKeyAddr = .RecipenName ' Collection Object of Recipe Names
End Select
End With

Call GetPrimaryKey (PKeyAddr)

End Function
 
You have to use Set with object variables:

Set PKeyAddr = .MenuCategory
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top