Solved

Disable Controls also disables Shortcut Keys

Posted on 2001-06-21
4
159 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
[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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

740 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