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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I find out the class of a custom object 1

Status
Not open for further replies.

RSfromCO

Programmer
May 3, 2002
149
US
I have defined several custom classes that are similar. I have a sub-report that needs to be passed one of these custom objects and then know which type of object it is dealing with.

I wanted to do something like:

Dim genericObject As Object

Set genericObject = Reports("MainReport").theObject

If genericObject.Class = "CustomClass1" then...
If genericObject.Class = "CustomClass2" then...
If genericObject.Class = "CustomClass3" then...

Any suggestions?
 
RSfromCO,
Add a property (string) to each of the Classes that you could call from your report?

CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Like CautionMP said.

Private mObjectType As String

Public Property Get ObjectType() As string
ObjectType = mObjectType
End Property

Public Sub Class_Initialize()
mObjectType = "Name of Class"
End Sub
 
TypeOf statement is what you're after.

If TypeOf yourVar Is Something Then
 
Craig,
Good tip. I did not know that, been spending my time rolling my own property. Also found out that you can use the
TypeName function which is supposedly more reliable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top