BeforeUpdate funktioniert nicht!
Knatterkopf
ich habe hier alles durchstöbert und raufe mir immer noch die Haare. Vorallem in dem Post https://www.herber.de/forum/archiv/140to144/t143076.htm steht die eigentliche Lsg. Nur bei mir will es nicht laufen und ich weiß zum Teufel nicht warum!!
Folgendes:
Meine Textbox will dieses Event nicht fressen! Was ich will geht aus dem Code hervor!
Kurz: Wenn das Datum nicht stimmt und man das Feld verlässt, so soll geschumpfen werden.
Private Sub TextBox1_BeforeUpdate(ByVal cancel As MSForms.ReturnBoolean)
Dim strDate As String
With Me.TextBox1
strDate = .Value
If IsDate(strDate) Then
If Not strDate = Format(strDate, "dd.mm.yyyy") Then
.SelStart = 0
.SelLength = Len(Text)
MsgBox "Bitte einen korrekten Datumswert eingeben! Format: dd.mm.yyyy"
cancel = True
End If
Else
MsgBox "Bitte einen korrekten Datumswert eingeben! Format: dd.mm.yyyy"
.SelStart = 0
.SelLength = Len(Text)
cancel = True
End If
End With
End Sub
Bestimmt weiß einer von euch Rat und Tat!
Viele Grüße
Adrian