473,396 Members | 1,913 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,396 software developers and data experts.

How to use keydown with code and cancel on completion

547 512MB
I want to use F11 with vba code only in a specific form, and then it must cancel this F11 function after executing this function. This is what i have but F11 stays active on closing, the application.It is a bit erratic.
It must be working similarly to "setwarning = true and false"
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  2. If KeyCode = vbKeyF11 Then
  3.      'KeyCode = 0   how do i add this?
  4.  
  5.       DoCmd.GoToControl ("RacetimingSF3")
  6. DoCmd.GoToRecord , "", acNewRec
  7.  
  8. 'How do i cancel F11 now?
  9.  
  10.  
  11.   End If
  12. End Sub
Oct 7 '11 #1

✓ answered by NeoPa

Neelsfer:
The current F11 keydown only works the first time i press it.
Isn't that what you want it to do? Although I can't see why that would be true looking at the code.

I would use something like :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  2.     Static blnDone As Boolean
  3.  
  4.     If KeyCode = vbKeyF11 _
  5.     And Shift = 0 _
  6.     And Not blnDone Then
  7.         Call txtHoldNumber1.SetFocus
  8.         blnDone = True
  9.     End If
  10. End Sub

3 3970
neelsfer
547 512MB
I have changed the code a bit.
I would rather like the F11 key to take me on my mainform (RaceSetupF) to a textbox called "txtHoldNumber1"
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  2. If KeyCode = vbKeyF11 Then
  3. txtHoldNumber1.SetFocus
  4.   End If
The current F11 keydown only works the first time i press it.

Any suggestions please.!!
ps i try to use Rfid and the software requires a keystroke = F11 in this case to go to a specific field or textbox.. From here the data is then copied into the database.
Oct 7 '11 #2
ADezii
8,834 Expert 8TB
Try setting the KeyPreview Property of the Form to Yes, and see what happens.
Oct 7 '11 #3
NeoPa
32,556 Expert Mod 16PB
Neelsfer:
The current F11 keydown only works the first time i press it.
Isn't that what you want it to do? Although I can't see why that would be true looking at the code.

I would use something like :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  2.     Static blnDone As Boolean
  3.  
  4.     If KeyCode = vbKeyF11 _
  5.     And Shift = 0 _
  6.     And Not blnDone Then
  7.         Call txtHoldNumber1.SetFocus
  8.         blnDone = True
  9.     End If
  10. End Sub
Oct 7 '11 #4

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

Similar topics

1
by: John | last post by:
Hello, I'm working with Dreamweaver MX and we started to develop our website with Javascript too. However, unlike "Eclipse" for Java developement I don't have the support for Javascript code...
1
by: Andy | last post by:
Hi folks, I have following problem: #include <map> .... std::map<long, long> myMap; myMap.
1
by: WindAndWaves | last post by:
Goodmorning Gurus Here is another of my questions..... When adding code to a control then access sometimes puts in a couple of 'parameters'. Can anyone tell me what the use of them is. I have...
21
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on...
5
by: ApexData | last post by:
This follows a previous post, when I was trying to capture a key pressed during the immediate opening of a form (ie in the first 3-secs before processing any of the code that followed it. It was...
1
by: kgerritsen | last post by:
I am building an application that will receive input from a barcode scanner. The barcode scanner is configured to append to the front value a single character and hyphen that identify the barcode...
9
by: pvsundarram | last post by:
hey, i am trying to cancel the keydown event for certain keycodes( for eg:- enter key ).But the cancelling of this event is not happening in firefox. Is there any way to cancel the event in the...
16
by: =?ISO-8859-1?Q?Ali_Servet_D=F6nmez?= | last post by:
I don't want to be so mean here, but how hard it could be be writing a freesoftware which would automatically/intelligently auto complete Python code? (I mean something that really does the job,...
1
by: ghjk | last post by:
I'm using ajax in my php site. In there I have two buttons named as submit and cancel. When I click submit button it validates data using ajax. (No need to use form for this). But the following...
2
by: learnaccess3 | last post by:
Dar team need u r help I am new to aceess . I am writign a query in access for finding the last name mathcing with criteria using Like operator. selct a,b,c from Table1 where last name like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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
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,...

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.