Jump to txtbx

R

Rod

How can I jump from textbox1 to textbox 3, skipping textbox 2 in the tab
order, because of the selection chosen in textbox1?
 
M

Michel

i would think something like:

If textbox1 = "value" then
me.textbox2.tabstop = false
end if


Michel
 
R

Rod

Sorry, Michael, I was not clear. My example was too simple. I would like to
jump to s specific txtbox name given the selection. Something like,

If selection is "Message" then jump to txtbox59.

The point is I mya want to jump over 1 or 30 controls regardless of the tab
order.

Thanks.
 
6

'69 Camaro

Hi, Rod.

Since it may be one or a lot of controls you want to skip when tabbing,
consider setting focus to that next control and not change the settings for
the tab order. Try:

If (Me!textbox1 .Value = "Message") Then
Me!textbox30.SetFocus
End If

If you want to play with the tab settings, it could get pretty difficult to
maintain:

If (Me!textbox1 .Value = "Message") Then
Me!textbox2.TabStop = False
Me!textbox3.TabStop = False
Me!textbox4.TabStop = False
' And so on.
Else
Me!textbox2.TabStop = True
Me!textbox3.TabStop = True
Me!textbox4.TabStop = True
' And so on.
End If

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
6

'69 Camaro

Hi, Rod.
Is the only way to jump to a specific control via manipulating tab
stops?

There are three ways: SetFocus to the specific control, set the controls
between the start and destination controls with the TabStop Property to
FALSE, or swap the TabIndex Properties of the control to be jumped over with
the TabIndex of a control that resides after the control to be jumped to.
For example:

If (Me!textbox1.Value = "Message") Then
Me!textbox2.TabIndex = 4
Else
Me!textbox2.TabIndex = 2
End If

This example will jump to the control with TabIndex = 3 when textbox1 =
"Message." Additional tabbing will jump to the control with the original
TabIndex = 4, then back to the control that was skipped. One may put this
"jumped over" control at the end of the Tab Order list, but tabbing will
eventually reach it.

The best way is usually to set focus on the necessary control.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
D

Douglas J Steele

I think a 4th alternative might be to put code in the LostFocus event of the
control to determine where it wants to go next.
 
6

'69 Camaro

Thanks, Doug. How could I forget? The fourth alternative, GoToControl, can
be put in the text box's OnLostFocus( ) event:

Private Sub textbox1_LostFocus()

If (Me!textbox1.Value = "Message") Then
DoCmd.GoToControl "textbox3"
End If

End Sub

;-)

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
 
D

Douglas J Steele

The purist in me dislikes GoTos <g>

Private Sub textbox1_LostFocus()

If (Me!textbox1.Value = "Message") Then
Me!textbox3.SetFocus
End If

End Sub
 
6

'69 Camaro

The purist in me dislikes GoTos <g>

Having been a C programmer before coming to the database world, I still
can't get over the use of GoTo for error handling in VBA.
Me!textbox3.SetFocus

You're repeating the first alternative. <g>
(But it's my choice too, as it's the most effective alternative.)

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
 
D

Douglas J Steele

Rereading the thread, I see where the confusion may be coming from! <g>

I was talking in terms of what event to put the code (LostFocus). You didn't
mention anywhere what event, so I was assuming you were talking about the
AfterUpdate event.
 
6

'69 Camaro

I was assuming you were talking about the
AfterUpdate event.

You're right on the money. I never considered the OnLostFocus( ) event
until you mentioned it. It got me to thinking whether there was anything
else I hadn't considered, and I remembered GoToControl. So thanks again for
the nudge to get my noggin going.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
 
Top