I'm writing some VBA code to dynamically position some elements on a form. What I would like to do is create a two dimensional array of references to 11 rows of label and text box objects, then step through the array and position each "row" differently based on the properties of the above rows.
Unfortunately, I cannot seem to find a way to store the references! The following code produces the error: "Object doesn't support this property or method"
Dim fields(10,10)
fields(0,0) = txtFirstName
If I assign an object to a single variable like so
Dim field
field = txtFirstName
MsgBox field.Top
Then I get no error message from the assignment, but the reference to field.Top gives me the error "Object Required".
Please, what am I doing wrong here. I'm new to stack overflow and VBA coding so forgive me if this is an easy fix, but I've leveraged my google-fu and I'm just not finding a solution. Many thanks to anyone who can help.
Dim field As Object, and then per @Tom Cannaert's response, use theSetkeyword when assigning an object variable.