473,468 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to disable function keys in access 2010

62 New Member
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 6647
zmbd
5,501 Recognized Expert Moderator Expert
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 Recognized Expert Moderator MVP
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 Recognized Expert Moderator Expert
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...
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
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.