Determining whether an object is a member of a collection in VBA

collections, ms-access, object, vba

Solution

Your best bet is to iterate over the members of the collection and see if any match what you are looking for. Trust me I have had to do this many times.

The second solution (which is much worse) is to catch the "Item not in collection" error and then set a flag to say the item does not exist.

Problem

How do I determine whether an object is a member of a collection in VBA? Specifically, I need to find out whether a table definition is a member of the `TableDefs` collection.

Original source