Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 26th, 2004, 03:26 PM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
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
Reply With Quote
  #2 (permalink)  
Old April 26th, 2004, 06:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Oxford, , United Kingdom.
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.
Reply With Quote
  #3 (permalink)  
Old April 27th, 2004, 06:58 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:25 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.