Solved

MS Access Send Keys {PGDN} alternative

Posted on 2014-01-07
6
396 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 500 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

This article will show you how to use shortcut menus in the Access run-time environment.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

777 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