473,569 Members | 2,870 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 "RaceSetupX CF".
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 1894
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
1741
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 page I have a clickable link to a function. The best html for that process seems to be: <a href="xxx" onclick="TheFunction(); return false">CLICK...
2
9786
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 in a link. that function can have parameters for URL and window name passed to it. This works peachy in Firefox (1.0). With IE 6 (6.0.29) on two...
2
4990
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 anyone done this before? I do not want to dynamically create my hyperlink on an ASP page, but rather a behind the scenes link that a user can paste...
2
1520
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 see anything Any ideas? Farris
1
6558
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> #include "stdafx.h" using namespace std; class IntNode
2
3740
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 event which will allow me to trap Value member detail when the user scrolling through the List items list? 2. How to assign dynamic values to...
1
1275
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: \'Jazzmatt\', caption: \'Mmmmmm Margaritas! And yes, this is me...\', left: 300});" value="Launch it from this Button!" /> and has to be triggered by this(or...
2
899
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 two link </a> I need a listenet that can understand and say : "hey somebody requested b.html." and will run some code, some db operations, and...
3
1359
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 window. So that's no good for me neither is scanf() it does the same thing. Next I decided to look in the ansi stdio.h file to find a keyboard...
2
1752
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
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7679
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.