Reputation: 123
I would like to pass the type of MS Access objects to a function. From an earlier question I know that you can test for TableDef, form, QueryDef, etc. types using TypeOf... is. But I do not know what the types of the results are and how to pass them to a new function that doesn't have access to the original object.
I'd like to be able to pass something like CStr(TypeOf(object)) but TypeOf doesn't seem to be able to be called outside of the TypeOf... is statement.
I guess I could create a helper function that tests for object types I'm interested in and returns a string or enum. But if someone knows how to pass the object type, that would be a lot simpler!
Upvotes: 1
Views: 432
Reputation: 123
Apparently there is already an enum for Access object types: the acObjectType enumeration, described on MSDN. This is used, for example, in the application.sethiddenattribute method. Unfortunately I only found this after creating my own enum for a different procedure I was writing.
Upvotes: 0
Reputation: 97131
I'm unsure exactly what you want, but wonder whether TypeName()
might be useful.
Here are a few examples from an Immediate window session:
? TypeName(CurrentDb.TableDefs("tblFoo"))
TableDef
? TypeName(CurrentDb.QueryDefs("qryFoo"))
QueryDef
DoCmd.OpenForm "Form3"
? TypeName(Forms!Form3)
Form_Form3
? TypeName(Forms!Form3!cboUserId)
ComboBox
Upvotes: 2