A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Enabling Multiple Controls



 
 
Thread Tools Display Modes
  #1  
Old April 14th, 2008, 01:25 AM posted to microsoft.public.access.forms
Rob
external usenet poster
 
Posts: 1,029
Default Enabling Multiple Controls

Hello All,

Is there a way to enable and disable all controls on a form via VBA?

Thanks,

Rob
  #2  
Old April 14th, 2008, 01:43 AM posted to microsoft.public.access.forms
Ken Snell \(MVP\)
external usenet poster
 
Posts: 2,506
Default 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  
Old April 14th, 2008, 01:58 AM posted to microsoft.public.access.forms
Rob
external usenet poster
 
Posts: 1,029
Default 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  
Old April 14th, 2008, 02:37 AM posted to microsoft.public.access.forms
magicdds
external usenet poster
 
Posts: 64
Default 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  
Old April 14th, 2008, 03:39 AM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default 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  
Old April 14th, 2008, 03:42 AM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default 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  
Old April 15th, 2008, 02:54 AM posted to microsoft.public.access.forms
Ken Snell \(MVP\)
external usenet poster
 
Posts: 2,506
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:15 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.