Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Disable all controls on a tab control except one dropdown on open

Posted on 2006-07-19
11
Medium Priority
?
476 Views
Last Modified: 2008-09-03
I have a form with a tab control on it.  On open I would like to have everything on the tabctl disabled (if applicable) with only one combo box enabled.  thanks in advance
0
Comment
Question by:H-SC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 17137989
The quick-and-dirty approach would be to mark them all as Enabled = No (Visible = No?) in Form Design, with your one combo box Visible = Yes, then save.  
That way, on open they're all disabled, and you can write code in your combo box's AfterUpdate event to make them Enabled = Yes.

Hope this helps.
-Jim
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 17138058
Way to do it in code is like this
I recommend putting it in a function so u can toggle


private sub EnableDisableControls(byval bEnable as boolean)

dim ctl as control

for each ctl in Me.Controls
    if ctl.ControlType = acTextBox or ctl.ControlType = acComboBox or ctl.ControlType = acListBox then
        if ctl.Name <> "mycombo" then
            ctl.Enabled = bEnable
        endif
    end if
next ctl

end sub


Now u call it passing in TRUE to enable, FALSE to disable

on your form_open, u can call this procedure passing in FALSE
   
0
 
LVL 1

Author Comment

by:H-SC
ID: 17138082
jim,

In most cases I do just that.  In this case, I would really like to have code that does the switch for all with the one exception.  This particular form has a ton of fields and controls on it thus... looking for some type of shortcut approach to this particular form.
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 1

Author Comment

by:H-SC
ID: 17138106
rockiroads,

thanks,

I will try...
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17138127
In that code I only check for textboxes, listboxes and dropdowns

If u have other editable controls, ensure u add them in,
checkbox is acCheckBox

if u want command buttons disabled,  then its acCommandButton


Ensure u set  "mycombo"  to be the control name of your combo that u want always enabled
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 17138177
Well, if you're only wanting to disable controls on the tab then surely you'd have to consider it separately from Me.Controls

Something like

    Dim ctl As Control
    Dim intPages As Integer
   
    For intPages = 0 To Me.TabControl.Pages.Count - 1
        For Each ctl In Me.TabControl.Pages(intPages).Controls
            ctl.Enabled = False
        Next
    Next

Or to use Rocki's method with a small alteration

for each ctl in Me.Controls
    if ctl.ControlType = acTextBox or ctl.ControlType = acComboBox or ctl.ControlType = acListBox then
        if ctl.Name <> "mycombo" and ctl.Parent.Name = "TabControlName" then '<<---change here
            ctl.Enabled = bEnable
        endif
    end if
next ctl
0
 
LVL 1

Author Comment

by:H-SC
ID: 17138381
rockiroads,

that worked perfect !!

many thanks
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17150234
No probs
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 17150276
Were all the controls you have on that form on your tab anyway? :-p

(But you perhaps imagined that the tab control makes a difference - a bit like a subform perhaps?  I believe that is a common assumption).
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17150311
Leigh u up l8, I still aint recovered, still serious sore throat but at least no fever anymore but cant find a car :(
laters mate, bedtime!
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 17150334
Late?  This is where my day just gets going ;-)
Hours of work ahead of me yet :-D
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question