PC Review


Reply
Thread Tools Rate Thread

How can I scroll page up/down with arrow keys

 
 
Rana
Guest
Posts: n/a
 
      27th May 2010
I am doing a project on Access 2003. I have a long form and needs to scroll
up/down often, That I am doing with my mouse well and Scrollbar. But I want
to scroll up/down with my up/down arrow keys. I want to scroll 1 inche down
everytime I press my down arrow.

I understand I have to write a code onkey up/down properties. Can someone
help me to write the code, plz?

Thanks,
 
Reply With Quote
 
 
 
 
Jeanette Cunningham
Guest
Posts: n/a
 
      28th May 2010
Here's some code from Allen Browne that does that.
Put the code in a standard module.
Call it like this:
Call ContinuousUpDown(Me, KeyCode), in the form's KeyDown event.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Call ContinuousUpDown(Me, KeyCode)
End Sub

You need to set the form's Key preview property to yes.


'start code ---------------------
Public Sub ContinuousUpDown(frm As Form, KeyCode As Integer)
'Purpose: Respond to Up/Down in continuous form, by moving record,
' unless the active control's EnterKeyBehavior is on.
'Usage: Call ContinuousUpDown(Me, KeyCode)
On Error GoTo Err_Handler
Dim strform As String

strform = frm.Name

Select Case KeyCode
Case vbKeyUp
If ContinuousUpDownOk Then
'Save any edits
If frm.Dirty Then
RunCommand acCmdSaveRecord
End If
'Go previous: error if already there.
RunCommand acCmdRecordsGoToPrevious
KeyCode = 0 'Destroy the keystroke
End If


Case vbKeyDown
If ContinuousUpDownOk Then
'Save any edits
If frm.Dirty Then
frm.Dirty = False
End If
'Go to the next record, unless at a new record.
If Not frm.NewRecord Then
RunCommand acCmdRecordsGoToNext
End If
KeyCode = 0 'Destroy the keystroke
End If
End Select

Exit_Handler:

Exit Sub

Err_Handler:
Select Case Err.Number
Case 2046, 2101, 2113, 3022, 2465 'Already at first record, or save
'failed, or The value you entered isn't valid for this field.
KeyCode = 0
Case Else
MsgBox Err.Number & " " & Err.Description
End Select
Resume Exit_Handler

End Sub

Private Function ContinuousUpDownOk() As Boolean
'Purpose: Suppress moving up/down a record in a continuous form if:
' - control is not in the Detail section, or
' - multi-line text box (vertical scrollbar, or
'EnterKeyBehavior true).
'Usage: Called by ContinuousUpDown.
On Error GoTo Err_Handler
Dim bDontDoIt As Boolean
Dim ctl As control

Set ctl = Screen.ActiveControl
If ctl.Section = acDetail Then
If TypeOf ctl Is TextBox Then
bDontDoIt = ((ctl.EnterKeyBehavior) Or (ctl.ScrollBars > 1))
End If
Else
bDontDoIt = True
End If

Exit_Handler:
ContinuousUpDownOk = Not bDontDoIt
Set ctl = Nothing

Exit Function

Err_Handler:
If Err.Number = 2474 Then 'There's no active control
Else
MsgBox Err.Number & " " & Err.Description
End If
Resume Exit_Handler

End Function
'end code---------------------


"Rana" <(E-Mail Removed)> wrote in message
news:67734FCB-7567-4A29-9ACD-(E-Mail Removed)...
>I am doing a project on Access 2003. I have a long form and needs to scroll
> up/down often, That I am doing with my mouse well and Scrollbar. But I
> want
> to scroll up/down with my up/down arrow keys. I want to scroll 1 inche
> down
> everytime I press my down arrow.
>
> I understand I have to write a code onkey up/down properties. Can someone
> help me to write the code, plz?
>
> Thanks,



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arrow Keys scroll across the page instead of to the next cell Lance Microsoft Excel Setup 1 23rd Sep 2009 09:02 PM
Arrow keys scroll the page instead of navigating through boxes BlueJ Microsoft Excel Worksheet Functions 2 7th Sep 2008 10:47 PM
Scroll with arrow keys Ken Benson Microsoft Word New Users 1 20th Oct 2006 09:50 PM
instead of moving cells my arrow keys scroll the page =?Utf-8?B?ZGdyYXk=?= Microsoft Excel Misc 2 22nd Dec 2004 02:01 PM
Arrow keys will not scroll =?Utf-8?B?VHJpY2lh?= Windows XP General 1 23rd Jan 2004 07:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:17 AM.