ich habe mit Hilfe eurer Kollegen eine UF erstellt, in welchen der Reihe nach Combobox, 6 Textboxes nochmals eine Combobox gefüllt werden.
Es sind jeweils Textbox_change und Textbox_Exit Ereignisse vorhanden.
Ich füge exemplarisch für TB1 diese hier ein:
Private Sub TextBox1_Change()
If TextBox1.Tag = "1" = True Then Exit Sub
If Len(TextBox1) = 2 Then
If InStr(TextBox1, ".") = 0 Then TextBox1 = TextBox1 & "."
ElseIf Len(TextBox1) = 5 Then
If Len(TextBox1) - Len(Application.Substitute(TextBox1, ".", ""))
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1 > "" Then
TextBox1 = CDate(TextBox1)
TextBox1.BackColor = vbGreen
Else
MsgBox "Bitte einen korrekten Datumswert eingeben! Format: dd.mm.yyyy"
With TextBox1
.SelStart = 0
.SelLength = Len(.Text)
End With
Cancel = True
End If
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1 = "" Then
MsgBox "Datum eingeben!!!"
Cancel = True
End If
If TextBox2 = "" And Label5 = "" Then
TextBox3.SetFocus
TextBox2.BackColor = vbGreen
ElseIf TextBox2 = "" And Label5 > "" Then
TextBox2.SetFocus
Else
Cancel = True
End If
End Sub
Das Ausfüllen des Formulars funktioniert einwandfrei.
Jetzt möchte ich aber einen Commandbutton, der die Eingaben rückgängig macht, einfügen.
Wenn ich jedoch hier einfüge - z. B. Textbox1 = "", dann tritt das Change-Ereignis ein und die Msgbox wird geöffnet - bitte Datum einfügen. Dies dann in Folge für alle Textboxes und Comboboxes. Wie kann ich dies verhindern. Gibt es hierfür eine Lösung?
Besten Dank für eure Hilfe.
Gruss
Peter