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
Solved

Set Next Focus

Posted on 2000-03-28
4
393 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library 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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

790 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