Refresh userform
BONJOUR FORUM ,
dans mon code je mets une contrainte dans un textbox ,
la contrainte est : si le champ saisi n'existe pas dans la base on donne l'accès de terminer le travail
sinon (si le champ existe dans la base) il bloque l'utilisateur de terminer le saisi des autres champs.
à ce moment la tous est bien ! mais si je teste un champs existant et aprés un autre non existant il este toujours bloqué , moi je veux rafraîchir le formulaire après chaque saisie interdit !
j'essaie avec
Me.Repaint
et
Load Me
mais ne fonctionne pas !!!
voila mon code dans le textBox qui contient la contrainte
Private Sub TextBoxLog_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim cell As Range, cell1 As Range
Dim no_ligne As Integer, i As Integer
Dim rôles_login_tracés As String, séparateur As String, rôles_login() As String
Dim ctrl As Control
With tracing_logins
Set cell = .ListColumns("Login Windows").Range.Find(Me.TextBoxLog.Value)
If cell Is Nothing Then: Exit Sub
'// remplissage contrôles du formulaire
login_saisi = Me.TextBoxLog.Value
no_ligne = cell.Row - .HeaderRowRange.Row
' MsgBox "Utilisateur existe , a dèja un compte "
MsgBox "Utilisateur existe dans la base , resaisir un autre "
'// Désactivation des contrôles
For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.TextBox Or TypeOf ctrl Is MSForms.ComboBox Then ctrl.Enabled = False
Next ctrl
Me.Repaint
'Me.TextBoxLog.Enabled = True
End With
End Sub
et pour mieux comprendre ceci la pièce jointe
entrer ----> UserFormCreation
saisir ---->TextBoxLog
merci d'avance
Bonjour,
Un essai ...
Private Sub TextBoxLog_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim cell As Range
Dim no_ligne As Integer
Dim ctrl As Control
With tracing_logins
Set cell = .ListColumns("Login Windows").Range.Find(Me.TextBoxLog.Value)
If Not cell Is Nothing Then ' < modif (if Not ...)
'// remplissage contrôles du formulaire
login_saisi = Me.TextBoxLog.Value
no_ligne = cell.Row - .HeaderRowRange.Row
'// Désactivation des contrôles
For Each ctrl In Me.Controls
If ctrl.Name <> "TextBoxLog" Then ' test pour éviter le 2e msgbox
If TypeOf ctrl Is MSForms.TextBox Or TypeOf ctrl Is MSForms.ComboBox Then ctrl.Enabled = False
End If
Next ctrl
MsgBox "Utilisateur existe dans la base , resaisir un autre "
Me.TextBoxLog = "" ' vider le textbox
Me.TextBoxLog.SetFocus ' lui redonner le focus
End If
End With
End Sub
ric
- Messages
- 4'097
- Excel
- 2021 FR 64 bits
- Inscrit
- 13/06/2016
- Emploi
- bénévole associations Goutte d'Or
Bonjour,
Pour rafraichir le formulaire :
Call réafficher_formulaire: Unload Me
Bonjour,
Un essai ...
Private Sub TextBoxLog_Exit(ByVal Cancel As MSForms.ReturnBoolean) Dim cell As Range Dim no_ligne As Integer Dim ctrl As Control With tracing_logins Set cell = .ListColumns("Login Windows").Range.Find(Me.TextBoxLog.Value) If Not cell Is Nothing Then ' < modif (if Not ...) '// remplissage contrôles du formulaire login_saisi = Me.TextBoxLog.Value no_ligne = cell.Row - .HeaderRowRange.Row '// Désactivation des contrôles For Each ctrl In Me.Controls If ctrl.Name <> "TextBoxLog" Then ' test pour éviter le 2e msgbox If TypeOf ctrl Is MSForms.TextBox Or TypeOf ctrl Is MSForms.ComboBox Then ctrl.Enabled = False End If Next ctrl MsgBox "Utilisateur existe dans la base , resaisir un autre " Me.TextBoxLog = "" ' vider le textbox Me.TextBoxLog.SetFocus ' lui redonner le focus End If End With End Sub
ric
merci RIC
Me.TextBoxLog.SetFocus
voici le nouveau code
Private Sub TextBoxLog_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim cell As Range
Dim no_ligne As Integer
Dim ctrl As Control
With tracing_logins
Set cell = .ListColumns("Login Windows").Range.Find(Me.TextBoxLog.Value)
If Not cell Is Nothing Then ' < modif (if Not ...)
'// remplissage contrôles du formulaire
login_saisi = Me.TextBoxLog.Value
no_ligne = cell.Row - .HeaderRowRange.Row
MsgBox "Utilisateur existe dans la base , resaisir un autre "
Me.TextBoxLog = "" ' vider le textbox
Me.TextBoxLog.SetFocus ' lui redonner le focus
End If
End With
End Sub
merciiii d'avance
Bonjour à tous,
Un essai ...
Private Sub TextBoxLog_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim cell As Range
Dim no_ligne As Integer
Dim ctrl As Control
With tracing_logins
Set cell = .ListColumns("Login Windows").Range.Find(Me.TextBoxLog.Value)
If Not cell Is Nothing Then ' < modif (if Not ...)
'// remplissage contrôles du formulaire
login_saisi = Me.TextBoxLog.Value
no_ligne = cell.Row - .HeaderRowRange.Row
MsgBox "Utilisateur existe dans la base , resaisir un autre "
Me.TextBoxLog = "" ' vider le textbox
If Me.TextBoxLog.Value = "" Then Cancel = True
End If
End With
End Sub
ric
Bonjour à tous,
Un essai ...
Private Sub TextBoxLog_Exit(ByVal Cancel As MSForms.ReturnBoolean) Dim cell As Range Dim no_ligne As Integer Dim ctrl As Control With tracing_logins Set cell = .ListColumns("Login Windows").Range.Find(Me.TextBoxLog.Value) If Not cell Is Nothing Then ' < modif (if Not ...) '// remplissage contrôles du formulaire login_saisi = Me.TextBoxLog.Value no_ligne = cell.Row - .HeaderRowRange.Row MsgBox "Utilisateur existe dans la base , resaisir un autre " Me.TextBoxLog = "" ' vider le textbox If Me.TextBoxLog.Value = "" Then Cancel = True End If End With End Sub
ric
SUPEEEER
ric