On 10 Nov 2004 12:57:00 -0800,
jm*******@gmail.com (Johnny M) wrote:
I have three custom classes in Access:
AdjustMgr
IDR
NPA
In the AdjustMgr, I have the following code (irrelevant code deleted):
.
.
Dim Doc as Object
.
.
Property Set Document(ByVal value as Object)
Set Doc = value
End Property
Doc will be an instance of the IDR or NPA class, depending on the circumstances.
Is this possible? When I set the Document property, I get the 438 error.
Thanks for the help,
Johnny
First, a comment. I recommend explicitly stating Public or Private on all
procedures and module variables, so it's clear if you intend them for internal
or external use.
Next, to answer your question. Yes, it's perfectly reasonable to use an
Object property to hold a class instance that could be of one type or another.
The only thing you lose is the ability for the compiler to tell you if you're
trying to pass an incorrect type, but that's not a problem when done in
moderation and for a good purpose. If you want to get fancier, you could
create another class to use as an interface, have both of your classes
implement that interface, and them use the interface type for the property in
the code above. Interfaces in VB are pretty klunky, though, so after using
them a lot for a while, I've backed off and tend not to use them so much.