Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Excel VB Form code tabbing

Status
Not open for further replies.

dprayner

Programmer
Oct 14, 2002
140
US
Hi people.

I have a user that has trouble tabbing textbox to textbox sometimes. The tabkey behavior, enterkey behavior, and multiline are set to false.

I beleive I have set the tabstop and tabindex properties correctly also.

My question is, is there a way to "hard" code the tab key in the textbox change event sub. For example:

Private Sub txtName_Change()
If Chr(9) Then 'Test to see if Tab key was hit
txtAddress.SetFocus ' move to the next textbox
End If
End Sub

Also when setting the tab indexes, should you start with 1 or 0. I currently have several controls which are disabled that have 0 as the tab index.

Thank you, DAVE
 
The TabIndex property starts at zero for the first control in the tab order. Don't duplicate this property value form more than one control. If a control is disabled (Enabled=False) it is skipped when tabbing so its TabIndex doesn't come into play. This can also be achieved for an enabled control by setting its TabStop property to False.

By setting these properties correctly, there is no reason why tabbing between the textboxes shouldn't work.


Regards,
Mike
 
Hi rmikesmith.

I am using two different frames on the VB Form so I have been starting the tabindexes as 1 in each frame.

Also if I start the first tabindex as 0 will setting another control to 0 athough the control Tabstop=False, cause an issue?

DAVE
 
The tab order of controls within different frames is independent so there is no conflict with identical TabIndex values between frames. The frames have their own tab order at a higher level, as well.

If the TabStop is False, the control's TabIndex is ignored. But if you reset TabStop = True and there is a TabIndex conflict, the VB environment will adjust these automatically. Probably not what you want.


Regards,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top