SetFocus funkt nicht
03.08.2021 11:13:54
Andreas
Private Sub TextBox1_AfterUpdate()
Dim txt As String
Dim F, Formate
txt = TextBox1.Text
Formate = Array("00-00-0000", "00-00-00", "00-00-0")
If Not IsDate(txt) Then
If IsNumeric(txt) Then
For Each F In Formate
If IsDate(Format(Val(txt), F)) Then
txt = Format(Val(txt), F)
Exit For
End If
Next
End If
End If
If IsDate(txt) Then
TextBox1 = Format(CDate(txt), "DD.MM.YYYY")
Else
MsgBox "Bitte korretes Datum eingeben."
TextBox1.SetFocus
End If
End Sub
Warum funktioniert der TextBox1.SetFocus nicht auf das gleiche Feld, das er eben überprüft hat?
Wenn Ich TextBox4.SetFocus einstelle, springt er auch in TextBox4 - nur nicht in die seinige zurück, die ja korrigiert werden soll.