Access JumpStart 2.0 | Blog

A Rapid Development Framework for Microsoft Access

Every Access control has a tag property which stores a string. I’ve used this property before to store information about a control I’ll need later. Kind of a poor man’s custom property.

Let’s say you want to store something in that tag property, but then someone else’s code also stores things in the same tag property? Wouldn’t it be nice to have custom tags that you know wouldn’t get overwritten?

'Using the normal tag property
Dim ctl As Access.Control

Set ctl = Forms("frmMain")("txtFirstName")

'Set my values for my purposes later on in a traditional tag.
ctl.Tag = "Top:" & ctl.Top & ",Left:" & ctl.Left

'But what if we made a class to hold our own custom tags?
'What might that look like?
Dim ctl As WrapControlTags
Set ctl = New WrapControlTags
ctl.Setup Forms("frmMain")("txtFirstName")
ctl.AccessControl.Tag = "Whatever"
ctl.AddTag("Top",ctl.AccessControl.Top)
ctl.AddTag("Left",ctl.AccessControl.Left)
Debug.Print ctl.Tags("Top"), ctl.Tags("Left")

I have a form resizing function that currently uses the actual form tags to store original size and position info. But instead I am planning to create a class to be able to implement the behavior shown in the custom tag section. There will be custom tags available as well as a passthrough to the original control object.

Sound interesting? Stay tuned for more.