Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

arrow buttons

Posted on 1998-09-17
11
Medium Priority
?
254 Views
Last Modified: 2010-04-30
VB5-DBList control - 2 cmdButtons on form - how do I program the 2 cmdButtons to act like the up and down arrow buttons to move through the list in the DBList control.
0
Comment
Question by:dstef
[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
  • 5
  • 4
  • 2
11 Comments
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1435391
Private Sub Form_Load()
    KeyPreview = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyLeft: Label1.Caption = "Left"
        Case vbKeyRight: Label1.Caption = "Right"
        Case vbKeyUp: Label1.Caption = "up"
        Case vbKeyDown: Label1.Caption = "Down"
    End Select
End Sub

0
 

Expert Comment

by:sjrl
ID: 1435392
My understanding of your question is that you want to be able to navigate the DBList using the 2 buttons. I think the following will work.

The VB SendKeys command sends keystrokes to the active window. So providing the DBList is active, sendkeys should work. To achieve this try

Sub cmdUpButton
   DBList.Activate
   SendKeys "{UP}"
End Sub

similarly SendKeys "{DOWN}" for the down button
0
 

Author Comment

by:dstef
ID: 1435393
What should I substitute for Label1 and Caption in solution one? The Up button name is "cmdUP". The caption on this button is "UP".
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 3

Expert Comment

by:a111a111a111
ID: 1435394
It is just an example.
0
 

Expert Comment

by:sjrl
ID: 1435395
I think that either a111a111a111 or myself has misunderstood the question. The example given by a111a111a111 allows you to detect which keys have been pressed, whereas my example simulates pressing the keys. Which do you want dstef?
0
 

Author Comment

by:dstef
ID: 1435396
I want my cmdUP and cmdDown to simulate the up and down arrows
On the second suggestion (sjrl) the Activate caused an error message. Program didn't recognize this event or method. Did I leave something out?
0
 

Author Comment

by:dstef
ID: 1435397
I was not clear in stating the problem and a1112a111a111 thought that I wanted to determine what key was pressed. Thanks. sjrl is on the right track, but I still need something clarified. Awaiting reponse from him to my comment.
0
 

Author Comment

by:dstef
ID: 1435398
Problem solved. Thanks sjrl. SendKeys was the right answer, only needed to use DBList1.SetFocus instead of Activate. I don't know how to rate this since it is my first use of this service, but thanks again. Good job.
0
 

Accepted Solution

by:
sjrl earned 400 total points
ID: 1435399
I suggested the .Activate to ensure the DBList was the active control and therefore received the keystrokes. I think there is a way to do this, it maybe .SetFocus or something like that.

Hope this helps.

In order to rate my answer you need to have an answer from me. So here's an "answer" for you to rate.


0
 

Expert Comment

by:sjrl
ID: 1435400
My previous response was added before I got your comment (10:56)
I've had a few problems with getting comments out of sync.
Glad Setfocus worked!
0
 

Author Comment

by:dstef
ID: 1435401
Thanks again.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

661 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