473,508 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to link a key on keyboard to a function

547 Contributor
When i press the "+" (ascikey 43)on my keyboard, i would like a function to work in a specific form called "RaceSetupXCF".
The code to be linked to "+" is below. The "+" must not be added to the fields of this form when pressing it.It must only work with the code below when the form is open.
Expand|Select|Wrap|Line Numbers
  1. Dim iRetValue As Long
  2.  If KeyAscii = 43 Then iRetValue = sndPlaySound(CurrentProject.Path & "\bell.wav", SND_ASYNC)
any suggestions please?
thx
May 2 '11 #1
2 1891
neelsfer
547 Contributor
Thought i got it working in the specific subform on main form using
Expand|Select|Wrap|Line Numbers
  1. Dim iRetValue As Long
  2. If Len(Nz(Me![RaceNumber].Text, 0)) = 0 And KeyAscii = 43 Then KeyAscii = 0 And iRetValue = sndPlaySound(CurrentProject.Path & "\bell.wav", SND_ASYNC)
  3.    Cancel = True
but my application crashes
But after adding error trapping code it seems to work again
May 2 '11 #2
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
You have to look at your FORMS Key_press event. For example:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyPress(KeyAscii As Integer)
  2.     If KeyAscii = 43 Then
  3.         iRetValue = sndPlaySound(CurrentProject.Path & "\bell.wav", SND_ASYNC)
  4.     End If
  5.  
  6.     'If you want to cancel out any other action 
  7.     '  that might come from the key (Such as 
  8.     '  form navigation, or typing in fields), 
  9.     '  you can clear the key by the following code:
  10.     KeyAscii = 0
  11.  
  12. End Sub
For the form to to receive key_press BEFORE the control that has the focus, you need to set the forms KeyPreview value to True.
May 2 '11 #3

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

Similar topics

2
1732
by: Dennis M. Marks | last post by:
I have seen partial answers to the following question but I am not sure of the best approach. I have a page that will only work with javascript. The link to the page indicates that. Within the...
2
9776
by: Chuck Martin | last post by:
I am having a most frustrating problem that references, web searches, and other resources are no help so far in solving. Basically, I'm trying to design a pop-up window to be called with a funciton...
2
4987
by: SAL | last post by:
I would like to create a VB.net function, that builds a dynamic hyperlink using System.Web.UI.WebControls.HyperLink, but I can not find any examples on how to generate a dynamic hyperlink. Has...
2
1511
by: farriswheel | last post by:
Hello All, I am trying to link a date function to a text box. I go into text box click on expression builder and insert the date function into the after update tab when I turn on the form I don't...
1
6551
by: ahoway | last post by:
I am having problems deleting a node from a link list. I need to delete the node which contains the number six. This is what I have so far..... Thank you in advance. #include <iostream>...
2
3738
by: Alam | last post by:
Hello All, Just couple of simple questions if someone can help: 1. I have a combobox and its properties are set as: Autocomplete mode = suggestappend Autocomplete source = List items Is there an...
1
1274
by: safuk2233 | last post by:
I need a function derived from: javascript: myLightWindow.activateWindow({href: \''. DIR_WS_IMAGES. $product_info .'\', title: \'Waiting for the show to start in Las Vegas\', author:...
2
898
by: Aykut Canturk | last post by:
there's an aspnet site. some pages are html and cannot be changed. (no javascript nor links can be changed). these pages have links. for example a.html calls b. html like: <a href="b.html"page...
3
1356
by: Levale | last post by:
Hello I'm new here. I need a function in 'C' that just pauses until the user hit's the enter key. I wanted to use getchar() however that function opens a stdio window which closes the main user...
2
1747
by: tmartiro | last post by:
Hi guys, I want to create link attach function like it implemented in facebook or google buzz. Do you know how to create this kind of stuff? Thanks in advance
0
7224
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
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7494
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...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5050
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
4706
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...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.