PC Review


Reply
Thread Tools Rate Thread

Auto tab to next control

 
 
=?Utf-8?B?UmljdGVy?=
Guest
Posts: n/a
 
      17th May 2006
if the current control is not null. What would be the best way to do this?
Do I have to refer to the next control, or is there a way to "resume tab
stops"?

tia
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWljaGFlbCBI?=
Guest
Posts: n/a
 
      17th May 2006
Hi.

In the Got Focus event of that control, it would be possible to check for
Null, and if so, loop through all controls on the form until you found the
one for which the tab index is the next highest than the tab index for the
current control, and then set the focus to it. However, this seems to be a
bit more trouble than it is worth, unless you are constantly rearranging your
controls. I think the best way would be to refer to the control directly:

Private Sub Control1_GotFocus()
If Not (IsNull(Me.Control1)) Then
Me.Control2.SetFocus
End If
End Sub

If you also want to check for an empty string in addition to Null, change
the If statement to something like:
If Not(Me.Control1 & "") = "" Then

By the way, have you considered the fact that your user will not be able to
use Shift-Tab to cycle through the controls in reverse order if this is
implemented? If a non-null Control1 automatically gives Control2 the focus,
a Shift-Tab from Control2 will appear to do nothing, since the focus will be
automatically set right back to Control2.

-Michael


"Ricter" wrote:

> if the current control is not null. What would be the best way to do this?
> Do I have to refer to the next control, or is there a way to "resume tab
> stops"?
>
> tia

 
Reply With Quote
 
=?Utf-8?B?UmljdGVy?=
Guest
Posts: n/a
 
      17th May 2006
Thank you Michael, and good points.



"Michael H" wrote:

> Hi.
>
> In the Got Focus event of that control, it would be possible to check for
> Null, and if so, loop through all controls on the form until you found the
> one for which the tab index is the next highest than the tab index for the
> current control, and then set the focus to it. However, this seems to be a
> bit more trouble than it is worth, unless you are constantly rearranging your
> controls. I think the best way would be to refer to the control directly:
>
> Private Sub Control1_GotFocus()
> If Not (IsNull(Me.Control1)) Then
> Me.Control2.SetFocus
> End If
> End Sub
>
> If you also want to check for an empty string in addition to Null, change
> the If statement to something like:
> If Not(Me.Control1 & "") = "" Then
>
> By the way, have you considered the fact that your user will not be able to
> use Shift-Tab to cycle through the controls in reverse order if this is
> implemented? If a non-null Control1 automatically gives Control2 the focus,
> a Shift-Tab from Control2 will appear to do nothing, since the focus will be
> automatically set right back to Control2.
>
> -Michael
>
>
> "Ricter" wrote:
>
> > if the current control is not null. What would be the best way to do this?
> > Do I have to refer to the next control, or is there a way to "resume tab
> > stops"?
> >
> > tia

 
Reply With Quote
 
=?Utf-8?B?TWljaGFlbCBI?=
Guest
Posts: n/a
 
      17th May 2006
Thanks, but I just realized that there is a problem with the code below.
Control1 would never be able to receive the focus, which is the reason for
the existence of the Shift-Tab issue I described below. Try the following
instead, which should be a better solution. "Control0" refers to the name of
the control which appears before Control1 in the tab order.

Private Sub Control1_GotFocus()

Dim ctl As Control
Set ctl = Screen.PreviousControl

If ctl.name = "Control0" Then
If Not (IsNull(Me.Control1)) Then
Me.Control2.SetFocus
End If
End If

End Sub

"Ricter" wrote:

> Thank you Michael, and good points.
>
>
>
> "Michael H" wrote:
>
> > Hi.
> >
> > In the Got Focus event of that control, it would be possible to check for
> > Null, and if so, loop through all controls on the form until you found the
> > one for which the tab index is the next highest than the tab index for the
> > current control, and then set the focus to it. However, this seems to be a
> > bit more trouble than it is worth, unless you are constantly rearranging your
> > controls. I think the best way would be to refer to the control directly:
> >
> > Private Sub Control1_GotFocus()
> > If Not (IsNull(Me.Control1)) Then
> > Me.Control2.SetFocus
> > End If
> > End Sub
> >
> > If you also want to check for an empty string in addition to Null, change
> > the If statement to something like:
> > If Not(Me.Control1 & "") = "" Then
> >
> > By the way, have you considered the fact that your user will not be able to
> > use Shift-Tab to cycle through the controls in reverse order if this is
> > implemented? If a non-null Control1 automatically gives Control2 the focus,
> > a Shift-Tab from Control2 will appear to do nothing, since the focus will be
> > automatically set right back to Control2.
> >
> > -Michael
> >
> >
> > "Ricter" wrote:
> >
> > > if the current control is not null. What would be the best way to do this?
> > > Do I have to refer to the next control, or is there a way to "resume tab
> > > stops"?
> > >
> > > tia

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Fill for tab control ploddinggaltn Microsoft Access VBA Modules 5 17th Jan 2008 06:52 PM
Auto populate a control =?Utf-8?B?R2FpbEs=?= Microsoft Access Form Coding 2 27th Jun 2006 04:50 PM
Auto populate a form control box based on different control box en =?Utf-8?B?Q1dD?= Microsoft Access Forms 0 26th Mar 2006 11:45 PM
auto scrollbar control John Microsoft Dot NET Framework 0 26th Nov 2003 11:18 AM
Auto-Sizing or Auto-Moving?? a Control Field Mae Microsoft Access Forms 1 7th Aug 2003 04:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:29 AM.