Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I control 'Enter' Key in a subform

0 views
Skip to first unread message

Drew Chaplin

unread,
Jun 27, 1998, 3:00:00 AM6/27/98
to

I have Access 97 and I am trying to figure out how to control the enter key
in a datasheet.
A form is no problem, just create a default control button and put the code
behind it.

I am wanting to control the enter key like it did in Access 2.0. Press the
enter key in a datasheet, goes to the next record and move to first field.
Also if you press the up or down arrow key it moves to the same field in
the next or prev record. I haven't figured out how to do it. Any
suggestions.

Many thanks
--
Drew Chaplin
Alexandria, IN
---
"a camera is a weapon, a stealer of images and souls; you are not a
bemused observer of the passing scene, you are a predator, and as
with most predators an acute sense of need plays a crucial role in the
determination to succced" -Bill
Coleman


Dev Ashish

unread,
Jun 27, 1998, 3:00:00 AM6/27/98
to

Hi Drew,

Try the "Enter Key Behavior" property of the control.

HTH
--
Dev Ashish (Just my $.001)
---------------
The Access Web ( http://home.att.net/~dashish )
---------------

Drew Chaplin wrote in message <01bda205$7fb2c380$LocalHost@laptop>...
:I have Access 97 and I am trying to figure out how to control the enter key

:

Andy Baron

unread,
Jun 29, 1998, 3:00:00 AM6/29/98
to

Look at Tools|Options|Keyboard

-- Andy

Chris Georgiou - TZOTZIOY

unread,
Jun 29, 1998, 3:00:00 AM6/29/98
to

On 27 Jun 1998 20:02:13 GMT, rumours say that "Drew Chaplin"
<Cha...@Netusa1.Net> might have written:

>I am wanting to control the enter key like it did in Access 2.0. Press the
>enter key in a datasheet, goes to the next record and move to first field.
>Also if you press the up or down arrow key it moves to the same field in
>the next or prev record. I haven't figured out how to do it. Any
>suggestions.

There is an option as to what the Enter key should do, in the Tools,
Options menu somewhere.
As for the up/down key, enter this subroutine in one of your modules:
----------------------------------
Public Sub ManageUpDown(KeyCode%, Shift%, ctl As Control, recno&)
On Error GoTo CheckErr

If KeyCode = vbKeyDown Then
If Shift = 0 Then
DoCmd.GoToRecord , , acNext
KeyCode = 0
ElseIf Shift = acShiftMask Then
Shift = 0
End If
ElseIf KeyCode = vbKeyUp Then
If Shift = 0 Then
If recno <= 1 Then ctl.SetFocus Else DoCmd.GoToRecord , ,
acPrevious
KeyCode = 0
ElseIf Shift = acShiftMask Then
End If
End If
Exit Sub

CheckErr:

If err = 2105 Then Beep: Resume Next
If err = 3314 Then
MsgBox "Form incomplete.", vbExclamation, "bla bla"
Resume Next
End If
End Sub
----------------------------------
Then set Key Preview=True for your subform.
In the subform's KeyDown event, add a line
---------------------
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
ManageUpDown KeyCode, Shift, Parent!cmbCltID, CurrentRecord
End Sub
---------------------
where the third argument is the parent's control you want to get the
focus upon pressing UpArrow in the subform's first record (it's easier
for the users than pressing CtrlShiftTab or using the mouse).

The only flaw is that when you open a combobox' dropdown list, you can't
use the up/down arrows; in that case, press Shift-up/down.

HTH
--
Greetings from Greece, I speak England very best,
TZOTZIOY, just an earthbound misfit, I
ICQ# 13397953 (when e-mailing remove the obvious after the .com part)

0 new messages