[AccessD] "Key up" not always "up"

Billy Pang tuxedoman888 at gmail.com
Wed Jun 13 18:40:30 CDT 2007


nevermind... I think I got it.  I must have gotten the definition of keydown
mixed up (it is when a key is pressed down as opposed to pressing the down
arrow key).

Using the following allows the pressing of the up/down arrow key to move the
cursor up/down respectively to its corresponding field.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next

If KeyCode = vbKeyUp Then
    DoCmd.GoToRecord , , acPrevious
ElseIf KeyCode = vbKeyDown Then
    DoCmd.GoToRecord , , acNext
End If
End Sub



On 6/13/07, Billy Pang <tuxedoman888 at gmail.com> wrote:
>
> Hello:
>
> In MS Access 2003, I'm trying to emulate the key up / down behavior of a
> datasheet for a continuous form but something quirky is happening.  Right
> now when the user presses the "down arrow" key, it moves down to the field
> directly below.  But when when pressing the "up arrow" key, it moves up and
> to the left???  does anyone know why this is happening?
>
> Here are the steps to recreate this:
>
> 1) begin with a table with three fields and about 10 records.
>
> 2) create a new form (continuous form) with the three fields showing.
>
> 3) on form properties, turn on key preview.
>
> 4) implement the following:
>
> Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
>    If KeyCode = vbKeyDown Then
>       DoCmd.GoToRecord , , acNext '<--  this moves cursor down perfectly
>    End If
> End Sub
>
> Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
>    If KeyCode = vbKeyUp Then
>       DoCmd.GoToRecord , , acPrevious ' <-- this moves cursor up and to
> the left???
>    End If
> End Sub
>
> 5) go to form view.  key down several times (works according to plan!)
>
> 6) key up several times (it does not go up directly; cursor goes up and to
> the left).
>
> thanks in advance,
>
> Billy
> --
> Billy Pang
> http://dbnotes.blogspot.com/
> "Once the game is over, the King and the pawn go back in the same box." -
> Italian proverb
>



-- 
Billy Pang
http://dbnotes.blogspot.com/
"Once the game is over, the King and the pawn go back in the same box." -
Italian proverb



More information about the AccessD mailing list