I am wondering if it is possible to have a dynamic enumeration.
Explanation: I have a function to add errors to an error log in ms access. The categories in my Enum variable are all in a table. If I use the function and enum as depicted below, it works just fine. The problem is however, that there is a possibility that the categories will change with time.
Enum category
Category1 = 1
Category2 = 2
etc... = n
End Enum
Public Function AddError(Current_order_ID As Long, Optional Error_Category As category)
'Add the error to the log
End Function
I have noticed that using DLookups and recordsets and actually everything in general will not work. While compiling, it throws an 'Invalid inside Enum'. Consulting MSDN gives me the following information: You tried to specify a string or some other invalid type as the value of an Enum member. The constant expression used to specify an Enum member must evaluate to type Long or another Enum type.
This tells me that an enum can hold only long types, hence the numbers, but also other Enum types.
What I am looking for: Is there some workaround, or method, to loop through a recordset or query and pass the values on to an array, and dynamically assign these values to an enumeration. Or perhaps it can be done by changing the source code/vba text itself?
Note: I know that there are a lot of other ways to add my errors to a log and I am able to do so, but for know I am just wondering if this is even possible to do.
I am looking forward to your reactions.