Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disable Controls also disables Shortcut Keys

Posted on 2001-06-21
4
Medium Priority
?
169 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 200 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

926 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