Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2004, 03:26 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default NextControl Property

In a form, you have a tab order for controls on the form. In VBA, you have the Screen.ActiveControl property that tells you where you are, you have the Screen.PreviousControl property that lets you place the focus on the previously focused control.

Where is Screen.NextControl? I would like to be able to (no matter where I am) move to the next control as though I have pressed a tab key. I know that

SendKeys "{TAB}", True

will work, if I know I'm sitting at the correct control.

But I use SendKeys as a last resort. They can cause trouble. Is there a way to do this without using the SendKeys and without having to specifically reference controls by name? I just want the focus to move to the next control in line. Screen.NextControl doesn't exist! :(


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
 
Old April 26th, 2004, 06:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Greg

The PreviousControl property gives a reference to whatever control previously had the focus - so unless you're running the new Access Clairvoyant, how can it possibly workout what next control you had in mind!?!:):)

Something like this might work to give a reference to the control with the next tabindex:

Code:
Public Function NextControl(ctrlCurrent As Control) As Control
Dim intIndex As Integer
Dim ctrlFor As Control

    intIndex = ctrlCurrent.TabIndex

    For Each ctrlFor In ctrlCurrent.Parent
        If ctrlFor.TabIndex = intIndex + 1 Then
            NextControl = ctrlFor
        End If
    Next

End Function
It 'll need some error trapping to deal with controls that don't have a tabindex and you'll need to deal with controls with tabstop set to false and I'm not sure what to do if the current control is the last one on the form...


Brian Skelton
Braxis Computer Services Ltd.
 
Old April 27th, 2004, 06:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Thanks, Brian. This is a start. Actually, no clairvoyance is needed... the next control is the one that is next in the tab index, so .NextControl would just go to what's next in the tab order. And that it DOES know. :)

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
Enable Property kekec3778 Beginning VB 6 2 January 8th, 2008 06:32 AM
property umeshtheone Beginning VB 6 2 May 18th, 2007 12:37 AM
the ConnectionString Property... coolb C# 3 September 26th, 2006 02:05 AM
The ConnectionString property...! rajesh0363 All Other Wrox Books 2 July 26th, 2005 01:55 PM
maxLength property crmpicco HTML Code Clinic 2 July 7th, 2005 06:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.