Solved

using page up and page down and the up and dow arrow keys

Posted on 2004-10-17
2
174 Views
Last Modified: 2010-05-02
My form has become so long that I am using VScroll bars to see all the text boxes which needed to be filled in. However as an added functionality I need to give the functionality of using the page up and page down geys to scroll the form or the arrow keys. How can I do that
0
Comment
Question by:anshuma
2 Comments
 
LVL 19

Accepted Solution

by:
Shauli earned 400 total points
Comment Utility
Set the form keypreview property to true.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next
Select Case KeyCode
    Case vbKeyPageDown
        VScroll1.Value = VScroll1.Max   'move to bottom of form
    Case vbKeyPageUp
        VScroll1.Value = VScroll1.Min    'move to top of form
    Case vbKeyDown
        VScroll1.Value = VScroll1.Value + 315    'you can adjust the speed by changing this number
    Case vbKeyUp
        VScroll1.Value = VScroll1.Value - 315     'you can adjust the speed by changing this number
End Select
End Sub

S
0
 
LVL 9

Assisted Solution

by:Shahid Thaika
Shahid Thaika earned 100 total points
Comment Utility
Doesn't the scroll bar control support the use of arrow keys. Anyway you can add the following event and code to do the scrolling in your form...


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
    Case vbKeyPageUp
        'scroll up
       
    Case vbKeyPageDown
        'scroll down
       
    Case vbKeyUp
   
    Case vbKeyDown
   
End Select
End Sub


Make sure 'KeyPreview' property of your form is set to true. Hope this answers your question :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now