Access JumpStart 2.0 | Blog

A Rapid Development Framework for Microsoft Access

So far my idea just kind of sucks. It’s ok, sometimes one just has a sucky idea.

I think what I’d really like to be able to do is something like this:

' In a form object, wouldn't it be nice to be able to do this?
Private Sub Form_Load()
   ' Ideal custom tags
   Me.txtName.Tags("OriginalTop") = Me.txtName.Top
End Sub

Ok, so is this even possible?

I don’t think so because the Form class is closed. You can’t change it’s properties or add new properties to it. Same with the Control class.

Now, maybe I could do the object this way instead.

' How about just an object?
Dim Tags As CustomTags

Private Sub Form_Load()
   ' Alternate, somewhat simple custom tags
   Tags(Me.txtName)("OriginalTop") = Me.txtName.Top
End Sub

In this case in order to implement this syntax I would need to create a default method for Tags and maybe return a collection or dictionary, or another custom class object with another default method to return the tag.

Alternatively, if I do it this way, is there a reason to not just use an existing Dictionary class either from Scripting.Dictionary or other pre-built dictionaries out there? That type of object already allows the syntax I’m showing I think… and already allows For Each loops and such. On the flip side, I could do a class which would require the Me.txtName argument to be an Access.Control type. I could also force the tag name to be a string and force the value of the tag to be a string.

Perhaps as I build it I would find other reasons as well. So I think I’ll try it. Using an existing dictionary class should make this relatively easy.