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

x
?
Solved

Set Next Focus

Posted on 2000-03-28
4
Medium Priority
?
413 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 150 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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 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…
Suggested Courses

722 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