Solved

Disable Controls also disables Shortcut Keys

Posted on 2001-06-21
4
158 Views
Last Modified: 2010-05-02
I have this code I use to make fields "read-only" on a form.  Works great, but found that it aslo disables the Menu Editor Shortcuts I use (F5, F9 etc).  How can I re-enable the keys, or have the code skip the disabling of these special keys altogether?

Code...
    Dim ctl As Control
    For Each ctl In Me.Controls
        If TypeOf ctl Is TextBox Or TypeOf ctl Is CheckBox Or TypeOf ctl Is ComboBox Or TypeOf ctl Is MaskEdBox Then
            ctl.Enabled = False
        Else
            ctl.Enabled = True
        End If
    Next
0
Comment
Question by:JAmarill
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
rkot2000 earned 50 total points
ID: 6215105
I never saw that kind of problem , but
try to put all controls on a frame and enable/disable that frame.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6215660
This has nothing to do with the topic but, could you change your code to this (i think is fast):

Dim ctl As Control
   For Each ctl In Me.Controls
       If not (TypeOf ctl Is label) Then   ' or the controls you have less quantity.
           ctl.Enabled = False
       Else
           ctl.Enabled = True
       End If
   Next
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6215663
Or some similar that doesn't use so many ORs.
0
 

Author Comment

by:JAmarill
ID: 6224704
Thanks! for the comments.  There were both useful.  I'm still not sure why the code I have causes the issue to begin with.  I tested the code in a test application by itself, and it works without disabling the shortcuts keys.  

I've given up and have decided just "reenable" the keys using the Form KeyDown event to detect the F keys I use and call the menus items directly.  I found the frame solution (while viable) would require me to re-cooridinate quite a bit of the form.

Thanks~!
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

831 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