Misleading Grouping Claim

PowerApps allows you to select a number of controls on a screen and create a group on them. Some properties of the group then apply to objects which are now part of it. One of the most useful I've found it to make the group visible. All of the members of that group are displayed or hidden without having to do so for each of them.

That would be a really cool feature to have in Access.

I use the tag property in code for grouping related controls to make them visible, hidden, locked, unlocked, clear their values, etc.
 
Same idea, but more code required I would expect.
Code:
Private Sub GroupVisibility(GroupName As String, Visibility As Boolean)
 
Dim ctl As Control
 
   On Error GoTo locErrorHandler
 
   For Each ctl In Me.Controls
      If InStr(ctl.Tag, GroupName) > 0 Then ctl.Visible = Visibility
   Next ctl

locExitHere:
   Exit Sub

locErrorHandler:
   ErrorHandler Me.Name, "GroupVisibility"
   If gErrorResponse = 1 Then Resume
   If gErrorResponse = 2 Then Resume Next
   Resume locExitHere

End Sub
 
Code:
Private Sub GroupVisibility(GroupName As String, Visibility As Boolean)
 
Dim ctl As Control
 
   On Error GoTo locErrorHandler
 
   For Each ctl In Me.Controls
      If InStr(ctl.Tag, GroupName) > 0 Then ctl.Visible = Visibility
   Next ctl

locExitHere:
   Exit Sub

locErrorHandler:
   ErrorHandler Me.Name, "GroupVisibility"
   If gErrorResponse = 1 Then Resume
   If gErrorResponse = 2 Then Resume Next
   Resume locExitHere

End Sub
Simple enough. (y)

But with a true Group, it would be:

Me.GroupofControlsName.Visible = visibility

and no need to poll all of the controls for the presence of the tag.
 
PowerApps allows you to select a number of controls on a screen and create a group on them. Some properties of the group then apply to objects which are now part of it. One of the most useful I've found it to make the group visible. All of the members of that group are displayed or hidden without having to do so for each of them.

That would be a really cool feature to have in Access.
Hi George,

You're absolutely right – being able to hide/show a whole group of controls at once is incredibly useful, and it's something we've all wished Access had natively (like PowerApps groups).

The good news is: you can do exactly that in Access right now, today, using the "Nifty Container" technique.

All you do is draw a simple rectangle around the controls you want to treat as a group (no tag property needed), and then with just a couple of lines of code you can hide or show everything inside that rectangle with one click – exactly like you're describing.

I've been using this for years, and it works perfectly for toggling visibility, highlighting empty fields, clearing values, enabling/disabling, etc.
Here's a quick 5-minute demo that shows it in action (including the hide/show you're after):

Nifty Container - Nifty Access​


And if you'd like to try it yourself, I'll attach a small sample database (zipped) to this post with the full working code – including the toggle hide/show button we just refined.
No third-party tools, no tag pollution, just pure VBA and a rectangle. 😊
Hope you find it useful!

Tom
(Nifty Access)

This was drafted and my instructions & from all my notes by GROK. For some strange reason GROK thinks my name is Tom ---
Note:- I also show several other methods including a class module but this is specifically for locking and unlocking controls but I think it could be adapted to hiding and unhiding controls that's on my website

Lock, Unlock Controls

 

Attachments

This suggests that a Rectangle control acts as a "container" that groups controls within its boundaries, allowing you to move them by dragging the Rectangle. However, this is not accurate and misrepresents standard Access behaviour.​


So getting back to your above observations, dragging a rectangle that has controls inside it does not drag the controls with it, as can be seen in the image below.

However, if you start drawing a container outside of the rectangle and drag through the rectangle, then it will grab the controls your container is sweeping through.

DragRectangle.png
 
Last edited:
Don't know what else to tell you. Still works for me. Mouse left click inside or outside then sweep.
Using Access 2020.
 
Last edited:
Don't know what else to tell you. Still works for me. Mouse left click inside or outside then sweep.
Using Access 2020.

There's a difference between dragging a rectangle object, and dragging a container.

If you start drawing a container outside a rectangle and sweep through the rectangle, then it will grab the rectangle and controls in it.

However, If you drag a rectangle with controls indide it, then it just moves the rectangle without grabbing the controls, regardless of Access 2020 or other edition.

Test it and let us know your results.

https___www.access-programmers.co.uk_forums_attachments_diagsweepoutsidebox-png.122375_.png
 
Last edited:
There's a difference between dragging a rectangle object, and dragging a container.

If you start drawing a container outside a rectangle and sweep through the rectangle, then it will grab the rectangle and controls in it.

However, If you drag a rectangle with controls indide it, then it just moves the rectangle without grabbing the controls, regardless of Access 2020 or other edition.

Test it and let us know your results.
I don't disagree with the difference. However, I was not addressing treating rectangle as a "container", I was addressing selecting multiple objects by click/sweep. I thought your assertion was that the rectangle could be selected along with other objects only if the sweep began outside the rectangle, per your comment "That only works if you start sweeping outside the box, as can be seen in the image below. If you start sweeping inside the box, then it just moves the box, but does not grab the controls."

That is what I objected to. Sweep can begin inside rectangle and still select objects.
 
I was addressing selecting multiple objects by click/sweep. I thought your assertion was that the rectangle could be selected along with other objects only if the sweep began outside the rectangle, per your comment "That only works if you start sweeping outside the box, as can be seen in the image below. If you start sweeping inside the box, then it just moves the box, but does not grab the controls."

That is what I objected to. Sweep can begin inside rectangle and still select objects.

 
You have arranged the rectangle at the front so only that is selected when you are inside it.
Move the rectangle control to the back. Then it will behave exactly as @June7 described.
 
You have arranged the rectangle at the front so only that is selected when you are inside it.
Move the rectangle control to the back. Then it will behave exactly as @June7 described.

It was already positioned in the back. I never bring boxes to the front.

AlreadyBackPosition.png
 
Last edited:
In my testing, it worked with rectangle positioned in front or back. In either case, have to click on "blank" space. Video in zip folder.
 

Attachments

Users who are viewing this thread

Back
Top Bottom