Solved

MS Access Send Keys {PGDN} alternative

Posted on 2014-01-07
6
405 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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!

 
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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

710 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