Solved

MS Access Send Keys {PGDN} alternative

Posted on 2014-01-07
6
386 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 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