Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error trying to add user-defined type to Dictionary object

Status
Not open for further replies.

avanderlaan

Programmer
Jul 11, 2002
156
I have the following declarations:
' in module.bas
Type StdsDocument
lDocId As Long
szDocumentNumber As String
szDocumentRevision As String
szDocumentName As String
End Type

' in a form
Dim documentDictionary As Dictionary

and am trying to execute
documentDictionary.Add rs(0), std

The error reported is "Compile error: Only user-defined typesin public object modules can be coerced to or from a variant or passed to late-bound functions."

The HELP explanation is "Only public user defined types defined in public object modules can be used as parameters or return types for public procedures of class modules or as fields of public user defined types. You attempted to use a public user defined type as a parameter or return type for a public procedure of a class module, or as a field of a public user defined type. Only public user defined types that are defined in a public object module can be used in this manner."

Could someone please explain what I am doing wrong and how to fix this? Thanx.
 
Try declaring your Type as Public:

Public Type StdsDocument Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
John,

I tried this last night (moving the type decl to module.bas) w/o effect. How should I Dim "std" for the following code?
documentDictionary.Add rs(0), std.
Thanx.
 
In the procedure:

Dim std as StdsDocument
Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Dim std as StdsDocument was my original declaration which I neglected to put in the first message; sorry. I am a C++ programmer and somewhat perplexed the VB object model. In any case I need a "collection" of user-type objects that I can create and destroy on the fly. Thanx.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top