Go Back   Access World Forums > Microsoft Access Reference > Sample Databases

 
Reply
 
Thread Tools Rating: Thread Rating: 4 votes, 4.50 average. Display Modes
Old 04-27-2017, 04:48 AM   #1
ridders
Newbee moderator
Gold Supporter
 
ridders's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 5,266
Thanks: 77
Thanked 1,283 Times in 1,199 Posts
ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough
Set a group of controls as visible/hidden, enabled/disabled or locked/unlocked

The attached utility demonstrates a way of setting the state of a group of controls at the same time using the controls' Tag property.

The properties that can be controlled are: .Visible , .Enabled, .Locked

However, some control types do not allow all of the properties.
For example labels can not be disabled or locked

For full details of control types & properties, see the table tblControlTypes

All the controls in the 2 forms have tags A, B, C or D.
Use the buttons to control the state of those with tags A, B, C
To ensure the form remains usable, controls with tag D remain visible, enabled & unlocked at all times!

The forms aren't intended to be elegant, just to show what can be done



UPDATED 29/04/2017:
For portability, all the functionality is now included in the module modControlState.
There are 3 procedures: ShowControls, EnableControls & LockControls

2 forms have been included - identical apart from colour
This is just to confirm that the forms are controlled independently as you would expect

To use this approach, just copy the module modControlState to your own project


An alternative approach suggested by Static & using parameter arrays rather than tags is listed in Module1 but has not been used here
Attached Images
File Type: png SetControls.PNG (71.7 KB, 988 views)
Attached Files
File Type: accdb SetControls - v2.accdb (864.0 KB, 444 views)

__________________
Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left and leave a comment.

New example databases:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by ridders; 05-21-2017 at 09:37 AM. Reason: Added inline image
ridders is offline   Reply With Quote
The Following 5 Users Say Thank You to ridders For This Useful Post:
GK in the UK (04-08-2018), gleesonc (07-05-2017), MrHans (04-27-2017), Tupacmoche (05-11-2018), usm01 (07-25-2017)
Old 04-01-2018, 08:55 AM   #2
Smokeeater
Newly Registered User
 
Join Date: Jan 2009
Location: Indiana
Posts: 42
Thanks: 8
Thanked 0 Times in 0 Posts
Smokeeater is on a distinguished road
Re: Set a group of controls as visible/hidden, enabled/disabled or locked/unlocked

Ridders, thank you for the reply. I would prefer to not tie these back to a tag on a control. The end user will unhide a large number of fields all at once, based on need. If not needed, them all of them in the module will stay hidden. If they are needed, I see them using a button to unhide the controls.

I may just have to keep the code tied to a command button if a module cannot be used.
Smokeeater is offline   Reply With Quote
Old 06-13-2018, 05:18 AM   #3
ridders
Newbee moderator
Gold Supporter
 
ridders's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 5,266
Thanks: 77
Thanked 1,283 Times in 1,199 Posts
ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough
Re: Set a group of controls as visible/hidden, enabled/disabled or locked/unlocked

Smokeeater
You referred to my reply but as your post has only just been approved, I can't remember if this was done via a PM.

To my mind this approach is perfectly suited to what you describe.
Users can click a button to show additional controls if that's what you want... However, normally I just build that into the code as needed

For example:
a) admin user logged in - show additional controls
b) user clicks Yes on a combo / option group => items shown are updated
etc, etc

__________________
Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left and leave a comment.

New example databases:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
ridders is offline   Reply With Quote
Old 06-13-2018, 11:44 PM   #4
Smokeeater
Newly Registered User
 
Join Date: Jan 2009
Location: Indiana
Posts: 42
Thanks: 8
Thanked 0 Times in 0 Posts
Smokeeater is on a distinguished road
Re: Set a group of controls as visible/hidden, enabled/disabled or locked/unlocked

Ridders,

Thank you for following up. All of the changes have been made and the end users are really satisfied with the hidden fields, and unhiding them with the buttons. I also threw in a couple other minor changes to splash it up a little. On to the next challenge!
Smokeeater is offline   Reply With Quote
Old 06-14-2018, 08:15 AM   #5
ridders
Newbee moderator
Gold Supporter
 
ridders's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 5,266
Thanks: 77
Thanked 1,283 Times in 1,199 Posts
ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough
Re: Set a group of controls as visible/hidden, enabled/disabled or locked/unlocked

Pleased it worked for you
BTW please see sticky post about reporting your own posts to moderated areas

__________________
Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left and leave a comment.

New example databases:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
ridders is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Setting a group of controls visible/hidden or enabled/disabled ridders Modules & VBA 9 04-27-2017 05:59 AM
Click Locked/Disabled controls, prompt for variable Futures_Bright Modules & VBA 0 08-06-2013 02:44 AM
Make Controls visible with Option group IanT76 Forms 4 07-09-2012 10:20 PM
Locked/unlocked aldeb Forms 1 06-13-2005 08:15 AM
locked and unlocked records Webster01 Forms 1 03-26-2002 08:25 AM




All times are GMT -8. The time now is 03:30 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World