|
-
Feb 25th, 2006, 01:43 PM
#1
Tab index Problem
Hi,
I have 25 text boxes in my form. While design i have assigned some tabindex.But while checking the entries in the text boxes i want to move the focus to the other box irrespective of the tab index. Is it possible..
Dana
-
Feb 25th, 2006, 02:40 PM
#2
Re: Tab index Problem
Use the SetFocus method of the control.
Text4.SetFocus
An error will occur if the control is not Visible or not Enabled so check before calling its SetFocus method
-
Feb 25th, 2006, 03:05 PM
#3
Re: Tab index Problem
it is not working.The control not moving even if setfocus.i have written this in validate event of text box
-
Feb 25th, 2006, 04:49 PM
#4
-
Feb 25th, 2006, 07:26 PM
#5
Re: Tab index Problem
If you want to tab from textbox to textbox see the How to trap the Tab key example in my signature.
-
Feb 25th, 2006, 11:48 PM
#6
PowerPoster
Re: Tab index Problem
 Originally Posted by danasegarane
Hi,
I have 25 text boxes in my form. While design i have assigned some tabindex.But while checking the entries in the text boxes i want to move the focus to the other box irrespective of the tab index. Is it possible..
Dana
you could assign alt-keys to the textboxes and then use the comination you need
-
Feb 26th, 2006, 12:03 AM
#7
Re: Tab index Problem
 Originally Posted by danasegarane
it is not working.The control not moving even if setfocus.i have written this in validate event of text box
It can't be done in validate event, do it in LostFocus event.
-
Feb 26th, 2006, 12:11 AM
#8
Re: Tab index Problem
it is not working.The control not moving even if setfocus.i have written this in validate event of text box
It appears you cannot use SetFocus in the Validate event. Keep your "validation" code in the Validate event but use the LostFocus to decide which control to move to next.
Example. 4 TextBoxes on a form. TabOrder is Text1, Text2, Text3, Text4. Change Text1 to a 3 or 4 and hit Tab
VB Code:
Private Sub Text1_Validate(Cancel As Boolean)
If Not IsNumeric(Text1.Text) Then
MsgBox "Invalid Data"
Cancel = True
End If
End Sub
Private Sub Text1_LostFocus()
Select Case Text1.Text
Case "3"
Text3.SetFocus
Case "4"
Text4.SetFocus
Case Else
'anything else and focus is set to Text2
'which is the next control in the TabOrder
End Select
End Sub
Private Sub Form_Load()
Text1.Text = "1"
Text1.MaxLength = 1
End Sub
This code did not work, Text2 was always the next control to get Focus.
VB Code:
Private Sub Text1_Validate(Cancel As Boolean)
If Not IsNumeric(Text1.Text) Then
MsgBox "Invalid Data"
Cancel = True
Else
Select Case Text1.Text
Case "3"
Text3.SetFocus
Case "4"
Text4.SetFocus
Case Else
'anything else and focus is set to Text2
'which is the next control in the TabOrder
End Select
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|