If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Enabling Multiple Controls
Hello All,
Is there a way to enable and disable all controls on a form via VBA? Thanks, Rob |
#2
|
|||
|
|||
Enabling Multiple Controls
Yes, though one must ask, why such a brute force approach?
You can loop through all the controls in a form this way: Dim ctl As Control For Each ctl in Me.Controls On Error Resume Next ctl.Enabled = True ' to enable Err.Clear Next ctl But, perhaps you can just set the AllowEdits property of the form to True or False as a much easier approach? -- Ken Snell MS ACCESS MVP "Rob" wrote in message ... Hello All, Is there a way to enable and disable all controls on a form via VBA? Thanks, Rob |
#3
|
|||
|
|||
Enabling Multiple Controls
Ken,
What I want is to make sure that the user always clicks on my New button to create a new record. If the controls are not enabled then the user would be forced to select the New or Edit button to gain access to the controls. If I set the AllowEdits property to false the user can still click on the controls. My New button does some other things in linked tables and I need to make sure that these things are done. I usually have form open in a new record but then those commands would not fire until the next new record is created leaving the current one without some support data needed to be created in other tables. Thanks for the help. That will work fine. "Ken Snell (MVP)" wrote: Yes, though one must ask, why such a brute force approach? You can loop through all the controls in a form this way: Dim ctl As Control For Each ctl in Me.Controls On Error Resume Next ctl.Enabled = True ' to enable Err.Clear Next ctl But, perhaps you can just set the AllowEdits property of the form to True or False as a much easier approach? -- Ken Snell MS ACCESS MVP "Rob" wrote in message ... Hello All, Is there a way to enable and disable all controls on a form via VBA? Thanks, Rob |
#4
|
|||
|
|||
Enabling Multiple Controls
I have a similar question:
Is there a way , from a command button on FORM1, to check which other forms are open, and set the ENABLED property of each of those forms to NO? Thanks Mark "Ken Snell (MVP)" wrote: Yes, though one must ask, why such a brute force approach? You can loop through all the controls in a form this way: Dim ctl As Control For Each ctl in Me.Controls On Error Resume Next ctl.Enabled = True ' to enable Err.Clear Next ctl But, perhaps you can just set the AllowEdits property of the form to True or False as a much easier approach? -- Ken Snell MS ACCESS MVP "Rob" wrote in message ... Hello All, Is there a way to enable and disable all controls on a form via VBA? Thanks, Rob |
#5
|
|||
|
|||
Enabling Multiple Controls
Dim ctl As Control
For Each ctl in Me.Controls On Error Resume Next ctl.Enabled = True ' to enable Err.Clear Next ctl I've never seen error suppression done like that, for this kind of hack, Ken! I've always looped, checking the type of each control to make sure that they had the given property before setting it, to avoid errors. Much easier this way! I'll file it away in my arsenal! Linq -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000/2003 Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200804/1 |
#6
|
|||
|
|||
Enabling Multiple Controls
Is there a way , from a command button on FORM1, to check which other forms
are open, and set the ENABLED property of each of those forms to NO? Forms have no Enabled Property! -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000/2003 Message posted via http://www.accessmonster.com |
#7
|
|||
|
|||
Enabling Multiple Controls
It's called being "lazy"..... or just short on time.... ! grin
Nothing wrong with what you do in your code... I do that in other situations for various reasons. And it's a "cleaner" way to develop. -- Ken Snell MS ACCESS MVP "Linq Adams via AccessMonster.com" u28780@uwe wrote in message news:82a52f6384bea@uwe... Dim ctl As Control For Each ctl in Me.Controls On Error Resume Next ctl.Enabled = True ' to enable Err.Clear Next ctl I've never seen error suppression done like that, for this kind of hack, Ken! I've always looped, checking the type of each control to make sure that they had the given property before setting it, to avoid errors. Much easier this way! I'll file it away in my arsenal! Linq |
Thread Tools | |
Display Modes | |
|
|