Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MS Access Send Keys {PGDN} alternative

Posted on 2014-01-07
6
Medium Priority
?
412 Views
Last Modified: 2014-01-22
So, I know I'm not supposed to use send keys, but I don't know how to do this any other way.  I now need to as the send keys {PGDN} does not work on my WIn 8 tablet.

I have a selection list "List1"

I want two big buttons for page up and page down as the guys in the field won't be able to use the little sliders to navigate up and down.

Is there an alternative to this:

Me.List1.setfocus
sendkeys "{PGDN}"

Thanks
0
Comment
Question by:hgj1357
  • 3
  • 2
6 Comments
 
LVL 17

Expert Comment

by:Kent Dyer
ID: 39763793
How about doing this programatically?

SELECT * FROM SOMETABLE WHERE column = "some_value"
0
 
LVL 2

Author Comment

by:hgj1357
ID: 39763799
The list has >1,000 items in it, so this would be a laborious approach. ALthough I suppose we could go

Field1 = Me.ID
Me.ID = Field1 + 10
Field1 = Me.ID
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 2000 total points
ID: 39764026
Well you could do something like this:
Me.List1 = Me.List1.ItemData(Me.List1.ListIndex + 10)
But this has some problems; one is that there would be a highlighted item when the button is pressed.  The other problem is that the scrollbar would still be visible and if that is used it would throw off the next visible section of the list.  

You are probably better off creating a subform that resembles a listbox -- that way you could hide the scrollbar.  Here's some code you could use (you would need to change NameOfSubformControl and update the iSkip constant to suit your purpose):
Private Sub btnScrollDown_Click()
'   Scroll Down
    Const iSkip As Integer = 10
    
    With Me.NameOfSubformControl.Form.RecordsetClone
        If .AbsolutePosition = -1 Then .Move 1
        
        .Move iSkip
        Me.NameOfSubformControl.Form.Bookmark = .Bookmark
        
        If .AbsolutePosition > 0 Then
            Me.btnScrollUp.Enabled = True
            Me.ArrowsPrev.Visible = True
        End If
        If .RecordCount - .AbsolutePosition < (iSkip + 1) Then
            Me.btnScrollUp.SetFocus
            Me.btnScrollDown.Enabled = False
        End If
    End With
    
    
End Sub

Private Sub btnScrollUp_Click()
'   Scroll Up
    Const iSkip As Integer = 10
    
    With Me.NameOfSubformControl.Form.RecordsetClone
        .Move -iSkip
        
        Me.NameOfSubformControl.Form.Bookmark = .Bookmark
        If .RecordCount - .AbsolutePosition > iSkip Then
            Me.btnScrollDown.Enabled = True
        End If
        If .AbsolutePosition = 0 Then
            Me.btnScrollDown.SetFocus
            Me.btnScrollUp.Enabled = False
        End If
    End With
    
End Sub

Open in new window

Ron
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 2

Author Comment

by:hgj1357
ID: 39801018
I ended up using this. It works surprisingly well.

Dim MyList As Integer
MyList = Me.List1.ListIndex
MyList = MyList + 12
Me.List1.SetFocus
Me.List1.ListIndex = MyList

12 is the number of items shown in the list, i.e. one page.
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39801070
Well, you really could shorten what you have to the following two lines:
Me.List1.SetFocus
Me.List1.ListIndex = MyList.ListIndex + 12

Open in new window

Or you could have used the single line I gave you earlier.  That way you wouldn't have needed to SetFocus to the listbox first:
Me.List1 = Me.List1.ItemData(Me.List1.ListIndex + 12)

Open in new window

In either case, you will still have the problems I pointed out earlier:
1. there would be a highlighted item when the button is pressed.
2. the scrollbar would still be visible and if that is used it would throw off the next visible section of the list.

Ron
0
 
LVL 2

Author Comment

by:hgj1357
ID: 39801101
I can live with those issues.  I have bigger ones!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft has changed the look and feel of Azure AD and Microsoft account sign-in pages so that you will have a more unified look and feel when moving between the two interfaces.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

971 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