Solved

arrow buttons

Posted on 1998-09-17
11
245 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
  • 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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 100 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 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

11 Experts available now in Live!

Get 1:1 Help Now