Solved

Set Next Focus

Posted on 2000-03-28
4
406 Views
Last Modified: 2008-02-01
How is it possible to set the focus to the next control in the tabindex list, without using Sendkeys "{TAB}" or other ugly patches?
0
Comment
Question by:Mustadio
[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
  • 2
4 Comments
 
LVL 4

Expert Comment

by:wileecoy
ID: 2665985
It depends on the control, but in most cases you can use .SetFocus.

For example.  With Text1 as a textbox  -

Text1.SetFocus

Will set the focus to your textbox.

If this doesn't work, please include more specific information.

Thanks.
0
 

Accepted Solution

by:
TheMask earned 50 total points
ID: 2665987
I tried this it worked perfect

Private Sub SetFocusToNextControl()

Dim CurrentControl As Control, NextControl As Control

'Get currently focused control
Set CurrentControl = Me.ActiveControl


If CurrentControl.TabIndex = Me.Controls.Count Then
    'If the Last control is the active one
    'set the next one to be any other one
    Set NextControl = Me.Controls(4)
Else
    'This portion sets the nextControl to
    'the next control in the tab list
    For i = 0 To Me.Controls.Count - 1
        Set NextControl = Me.Controls.Item(i)
        If NextControl.TabIndex = CurrentControl.TabIndex + 1 Then Exit For
    Next
End If

'Finally setting the focus
NextControl.SetFocus

End Sub

Enjoy :))
0
 

Author Comment

by:Mustadio
ID: 2685815
Hmmm... I was asking for a command which would have done the thing, since it was actually the way I was doing it myself.  It was what I was calling "patch"...
So, must I conclude there is no true way to do it, instead of making a loop and trying everything?
I guess I would accept your answer anyway...
0
 

Expert Comment

by:TheMask
ID: 2686438
Mustadio, yeah i think i got what do u mean, you was looking for a built in function.
You know i didn't look if this functionality is available as an API call,anyway i will look and i well tell you if i found something
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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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
Course of the Month6 days, 4 hours left to enroll

627 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