Trying to group a set of Controls into a Frame for Access 2007

scott56

New member
Local time
Yesterday, 18:46
Joined
Feb 14, 2009
Messages
6
Hi,

I am using Access 2007 for this first time and I am trying to group a set of controls (textbox, combo and listbox)....so that I can then enable that frame or disable it in one statement.

I was able to do this in Excel forms, but I cannot seem to get the Frame control to recognise the controls within it...the frame.enable works for the frame but not the controls in it...

Any suggestions would be appreciated.

Thanks
Scott
 
I've answered this in the Access newsgroup, Scott, but since you've also posted it here, I'll answer it here, as well. That way anyone wandering by this site can see it too!

The way you "group" controls for this kind of manipulation is to use the Tag Property. In form Design View, select the control(s) then got to Properties - Other and enter a value in the Tag Property. Don't get confused if you see a SmartTag Property! This is something else entirely!

For the purposes of this demo, we'll make the Tag Property Marked.

Enter this in the Tag Property box (without quotation marks.)

Also, for purposes of this demo, we'll change the Enabled Property of the tagged controls to Enabled = False. You can, of course, use the code to set any property that the particular control type has.

Then, in an appropriate event, use this code.

Code:
Dim ctrl As Control

For Each ctrl In Me.Controls
   If ctrl.Tag = "Marked" Then
      ctrl.Enabled = False
   End If
Next ctrl

Be sure that the controls that are tagged actually have the property you're trying to change, or you'll get an error! For instance, tagging a label control and then trying to change the Enabled property will error out, because labels don't have an Enabled property.
 
Thanks for that.....

I will try one of the suggested methods and I am sure it will work....I had thought that the behaviour of the Frame control would be the same in Access as it is Excel....looks like I was wrong

Scott
 
Its a misconception many people have, right along with assuming that Visual Basic and Visual Basic for Applications is the same, or even VBA for Access and VBA for Excel, for that matter!

They all come from one common language but each has been modified extensively depending on the individual needs. I understand from seasoned Access developers who have made the moce from Excel to Access that it really requires quite a bit of "un-learning!"

Good luck!
 

Users who are viewing this thread

Back
Top Bottom