Solved

Disable Controls also disables Shortcut Keys

Posted on 2001-06-21
4
155 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now