Solved

Disable Controls also disables Shortcut Keys

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add a task in Outlook from access 11 43
VBA - If Bookmark = "XXBOOKMARKXX" then 15 64
MS SQL Update query with connected table data 3 78
transition to visual .net from vb6 5 79
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.
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 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…
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…

732 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