473,401 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

how to disable function keys in access 2010

I want to disable function keys in access 2010,for that i am using code on forms on key down event.
Code is
Expand|Select|Wrap|Line Numbers
  1. 'The forms Key Preview property must be set to Yes
  2. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  3.  
  4.     Select Case KeyCode
  5.         Case vbKeyDelete
  6.             MsgBox "The Delete key was Pressed"
  7.             KeyCode = 0
  8.         Case vbKeyF1
  9.             MsgBox "The F1 key was Pressed"
  10.             KeyCode = 0
  11.         Case vbKeyF2
  12.             MsgBox "The F2 key was Pressed"
  13.             KeyCode = 0
  14.         Case Else
  15.             'MsgBox "No match!" 'testing
  16.     End Select
  17.  
  18. End Sub
  19.  
This works well but i want to create module and that module will be called in startup form and it will be applicable to call forms and reports.
Is it possible
Thank you in advance
Jan 10 '14 #1

✓ answered by NeoPa

I would suggest a slight modification.

TrapFunction() should, indeed, be a function procedure, rather than a subroutine procedure as shown.

The call to it should assign KeyCode to the result.
Expand|Select|Wrap|Line Numbers
  1. Public Function TrapFunction(KeyCode As Integer) As Integer
  2.     'blah di blah
  3.     TrapFunction = {whatever}
  4. End Function
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) 
  2.     KeyCode = TrapFunction(KeyCOde)
  3. End Sub
The rest of the post (#2) is well worth checking out too, as it deals with a very powerful technique to help secure your databases.

3 6640
zmbd
5,501 Expert Mod 4TB
Create the procedure in a standard code module using parameter, for example
Expand|Select|Wrap|Line Numbers
  1. sub trapfunction(byval keydown as Integer)
  2. 'remaining code omitted (^_^)
Then for each form where you want to trap the function keys in the Keydown event, call the procedure
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) 
  2. Call trapfunction(KeyCOde)
  3. End Sub 
There is also the AutoKeys macro... it is one of the only special case macros I use as I trap the [F1] and [F11] keys using this macro, even if the bypass key is used, the AutoKeys macro usually works.... be very careful using this macro as you can lock yourself out of things you need.
Jan 10 '14 #2
NeoPa
32,556 Expert Mod 16PB
I would suggest a slight modification.

TrapFunction() should, indeed, be a function procedure, rather than a subroutine procedure as shown.

The call to it should assign KeyCode to the result.
Expand|Select|Wrap|Line Numbers
  1. Public Function TrapFunction(KeyCode As Integer) As Integer
  2.     'blah di blah
  3.     TrapFunction = {whatever}
  4. End Function
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) 
  2.     KeyCode = TrapFunction(KeyCOde)
  3. End Sub
The rest of the post (#2) is well worth checking out too, as it deals with a very powerful technique to help secure your databases.
Jan 10 '14 #3
zmbd
5,501 Expert Mod 4TB
after reading Neopa's suggestion, the function certainly makes more sense. I was only thinking about trapping the key, and not what to do withit afterwards.
Jan 10 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Derek White | last post by:
Ok here's the deal. We are finally getting DSL again... but our PC is in the living room... and the youngest has figured out that if he hits the right keys... he can bring up Internet Explorer....
3
by: Armando | last post by:
Apologies if this has been covered recently - I lurked and saw nothing. I have an application that does ticketing at a three-screen movie theatre, and I'm using the function keys F1 thru F12...
5
by: jaad | last post by:
Hello, I have a database that was written in access 2007 on my pc. I wanted to work off site with the database so I uploaded it onto my laptop which is loaded with access 2010 beta. When I...
2
by: LaGena White | last post by:
I need to obtain the sum (BillTotal)of InvoiceTotal plus DeliveryCharge. That is easy. I must also use IIF function to add $5.00 to BillTotal if delivery was made in a certain City, otherwise just...
4
by: jbrumbau | last post by:
Hello, In Access 2010/2007, how do you prevent users from flipping into design view from the ribbon? I do not want to hide the entire ribbon (DoCmd.ShowToolbar "Ribbon", acToolbarNo) or even the...
1
by: billwilson | last post by:
IS there a way to disable the Access 2010 Hyperlink Security warning(s) without changing the registry? If not, is the registry change the same as 2007? I am running XP. Thanks in advance, ...
4
beacon
by: beacon | last post by:
Hi everybody, My title may not exactly describe my issue, so please forgive my lack of creativity today. I've got a database that was created in Access 2003 that I've opened in Access 2010. I...
17
twinnyfo
by: twinnyfo | last post by:
Hey coders, Has anyone heard anything about the Date() function no longer working (or working differently in MS Access 2010? I have an MS Access 2007 DB that has worked perfectly, however, we...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.