Erreur Focus textbox
Résolu/Fermé
sormick
-
Modifié par pijaku le 27/01/2015 à 14:11
f894009 Messages postés 17185 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 15 avril 2024 - 27 janv. 2015 à 15:52
f894009 Messages postés 17185 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 15 avril 2024 - 27 janv. 2015 à 15:52
2 réponses
f894009
Messages postés
17185
Date d'inscription
dimanche 25 novembre 2007
Statut
Membre
Dernière intervention
15 avril 2024
1 701
27 janv. 2015 à 14:30
27 janv. 2015 à 14:30
Bonjour,
en anglais, mais facile a comprendre:
https://www.excelforum.com/excel-programming-vba-macros/530311-vba-control-tab-index.html
en anglais, mais facile a comprendre:
https://www.excelforum.com/excel-programming-vba-macros/530311-vba-control-tab-index.html
f894009
Messages postés
17185
Date d'inscription
dimanche 25 novembre 2007
Statut
Membre
Dernière intervention
15 avril 2024
1 701
27 janv. 2015 à 15:52
27 janv. 2015 à 15:52
Re,
code corrige pour d'autres au cas ou:
code corrige pour d'autres au cas ou:
Private box As MSForms.TextBox Private Sub TextBox1_enter() Dim TabTxt As Integer Set box = TextBox1 '????????????????? box.Value = ListBox1.Value TabTxt = box.TabIndex + 1 Call SetFocusByTabIndex(Me, TabTxt) End Sub Sub SetFocusByTabIndex(ByRef MaForm As Object, iTab As Integer) On Error Resume Next Dim ctl As Control For Each ctl In MaForm.Controls If ctl.TabIndex = iTab Then ctl.SetFocus x = ctl.Name Exit For End If Next ctl End Sub
27 janv. 2015 à 14:52
je n'arrive pas à le faire fonctionner.
j'ai mis le code:
Sub SetFocusByTabIndex(frm as Form, iTab as Integer)
On Error Resume Next
Dim ctl as Control
For each ctl in frm.Controls
If ctl.TabIndex = iTab Then
ctl.SetFocus
Exit For
End If
Next ctl
End Sub
dans un module , puis j'ai mis le code:
Call SetFocusByTabIndex(Me,3) dans la listbox
l'erreur qui s'affiche est:
type défini par l'utilisateur non défini
27 janv. 2015 à 15:27
Marche pas, code non teste (ecrit au debut).
Vous envisagez de faire cette manip pour plusieurs textbox ou pas ???
27 janv. 2015 à 15:36
je commence à saisir sur la textbox1, une liste de valeurs s'affiche sur la listbox.
je clique dessus.la valeur cliqué s'affiche sur la textbox1 puis automatiquement il passe à la textbox suivante. et ainsi de suite pour toutes les textbox.
il y a un total de 35 textbox
27 janv. 2015 à 15:46
voici le code que j'ai trouvé à mettre sur la listbox:
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.TabIndex = box.TabIndex + 1 Then
ctl.SetFocus
Exit For
End If
Next
bonne journée à tous!!