473,398 Members | 2,088 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,398 software developers and data experts.

Keyboard move after enter

In a continuos form, ¿how can I get that the Enter on a field changes to the same field, next record, and not to the next field (moving vertically and not horizontally)?
I found an example that changes the behaivor of the Enter Key to "Don't move":

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  2.     If KeyCode = 13 Then
  3.         KeyCode = 0
  4.     End If
  5. End Sub
But I need to move to the next record of the same field (move down). I tried to set KeyCode = vbKeyDown but also this key move to the next field (moves right). ¿What should I set the KeyCode?
Oct 4 '11 #1

✓ answered by NeoPa

Try out :

Expand|Select|Wrap|Line Numbers
  1. 'Form_KeyDown only runs if the form's .KeyPreview property is True.
  2. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  3.     Dim intWrk As Integer
  4.  
  5.     If KeyCode = vbKeyReturn Then
  6.         'No reliable way to determine if we're already on the last record.
  7.         On Error Resume Next
  8.         If Not Me.NewRecord Then Call DoCmd.GoToRecord(Record:=acNext)
  9.         On Error GoTo 0
  10.         KeyCode = 0
  11.     End If
  12. End Sub
I would advise handling the Shift value too if you want your code to work intuitively for the operator.

7 1092
TheSmileyCoder
2,322 Expert Mod 2GB
Try looking at modifying the Tab Order as well as the Tab Stop property.

The Tab stop will indicate whether focus will move to that control or not, when you press tab (and also when you press enter I believe).

The tab order indicates the order in which the tab key moves around the form.

You also need to look at the cycle property and see whether its set to "Current Record" or "All Records", this indicates when pressing Tab whether or not the cycling should move to the next record, when at the last control.
Oct 4 '11 #2
NeoPa
32,556 Expert Mod 16PB
Try out :

Expand|Select|Wrap|Line Numbers
  1. 'Form_KeyDown only runs if the form's .KeyPreview property is True.
  2. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  3.     Dim intWrk As Integer
  4.  
  5.     If KeyCode = vbKeyReturn Then
  6.         'No reliable way to determine if we're already on the last record.
  7.         On Error Resume Next
  8.         If Not Me.NewRecord Then Call DoCmd.GoToRecord(Record:=acNext)
  9.         On Error GoTo 0
  10.         KeyCode = 0
  11.     End If
  12. End Sub
I would advise handling the Shift value too if you want your code to work intuitively for the operator.
Oct 4 '11 #3
@TheSmileyCoder: Thank you for your answer, but the problem is that I need this behavior with all the columns: Column #1: Rec #1, #2, #3, Then Column #2: Rec #1, #2, #3 and so on.
__________________________________________________ _
@NeoPa: Thank you! That was exactly what I needed!
Oct 4 '11 #4
NeoPa
32,556 Expert Mod 16PB
Arturo, responding politely to all comments in your thread is a good way to get yourself a good reputation around here. Nice start :-)

PS. I'm pleased that worked for you.
Oct 4 '11 #5
NeoPa, Thank you again! You saved me many work hours!
Oct 4 '11 #6
TheSmileyCoder
2,322 Expert Mod 2GB
Im pleased that NeoPa's solution worked for you. I was originally contemplating whether to include code similar to Neo's in my post but decided to start by keeping it simple. I sometimes have a tendency to "oversolve" and thus overcomplicate issues. :)
Oct 4 '11 #7
TheSmileyCoder, Thank you for your interest.
Oct 4 '11 #8

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

Similar topics

1
by: Scott Shaw | last post by:
Hi all, I was wondering if you could help out with this problem that I am having. What I am trying to do is detect keyboard input in a while loop without halting/pausing the loop until the key is...
3
by: Andrus Moor | last post by:
I want to use the keyboard keys for navigation in menu: 1. Alt+hotkey must activate menu bar 2. Left and right arrow must move between menus, 3. Up and Down arrow move between menu items. 4....
3
by: Tomasz \Boruh\ Borowiak | last post by:
Does anybody have any idea how to write a c++ console application which simulates the mobile phone keyboard ? for Example: when i write SMS I hit 2 - I get "a" I hit 22 - I get "b" I hit 222...
2
by: MJC | last post by:
Hi All, I just built a database in Access XP/Win XP and am having an issue with the enter key behavior when the database is run under Windows 2000. If you use the enter key to tab through the...
7
by: (Pete Cresswell) | last post by:
I've got KeyDown coding and it fires when other keys are pressed, but when Enter is pressed, nothing. I'd like to support the (standard?) Windows behavior of executing DblClick processing when...
3
by: Geoff G | last post by:
I want to prevent the focus moving to the next field in a form after pressing enter. I want to do this for only one specific form, I don't want to change the keyboard behaviour for the whole...
0
by: Ray | last post by:
I have English Windows XP Pro and Office 2003 Pro on my computer. When I enter data into fields of tables, queries and forms of Access 2003, it automatically switches to Chinese keyboard input. ...
2
by: Diffident | last post by:
Hello All, How can I force the control to go to click event handler if a keyboard's enter key is pressed instead of the user clicking the button. I remember that we need to create a hidden...
7
by: ManWithNoName | last post by:
If you have a form with x input and two or more buttons, how do you control which button has preceding when the user hits the keyboard key "enter"? Currently it seems to be determined in a...
1
by: Techno3000 | last post by:
import java.io.*; import java.awt.*; import hsa.Console; public class Calculator { static Console c; public static void main (String args) throws IOException
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: 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
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
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...
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...
0
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...

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.