auf meiner Userform habe ich unter anderem 2 Comboboxen.
Mit meinem Code überprüfe ich den Inhalt der beiden Boxen nach bestimmten Parametern, z.B Gleichheit.
Wenn der Inhalt der beiden so ausgewählt wurde, dass er gleich ist, erscheint eine MsgBox.
Bis hier funktioniert alles wie es soll.
Wenn man die MsgBox mit OK schließt, erscheint die selbe Box nochmal und ich muß sie nochmals schließen.
Der Fehler kommt warscheinlich daher, dass ich mit dem Event Change() beide Comboboxen überprüfe und die Abfrage für beide Boxen fast identisch ist, es somit auch 2 MsgBoxen gibt. Warscheinlich erscheint z.B. bei Gleichheit der Inhalte, die MsgBox von Combobox1 und danach die MsgBox von Combobox2.
Was muß ich machen, damit nur eine MsgBox erscheint?
mein Code:
Private Sub cboGesellschaft_Konto_Change()
If Me.cboGesellschaft_Konto = "DA/Allgemeines Lewa" And Me.cboGesellschaft_Konto_intern = "DA/ _
Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "DA/Kontokorrent Lewa" And Me.cboGesellschaft_Konto_intern = "DA/ _
Kontokorrent Lewa" _
Or Me.cboGesellschaft_Konto = "DA/Treuhand Lewa" And Me.cboGesellschaft_Konto_intern = "DA/ _
Treuhand Lewa" _
Or Me.cboGesellschaft_Konto = "AS/Allgemeines Lewa" And Me.cboGesellschaft_Konto_intern = "AS/ _
Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "LB/Allgemeines Lewa" And Me.cboGesellschaft_Konto_intern = "LB/ _
Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "LHB/Allgemeines Lewa" And Me.cboGesellschaft_Konto_intern = "LHB/ _
Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "AW/Allgemeines Lewa" And Me.cboGesellschaft_Konto_intern = "AW/ _
Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "AW/Treuhand Lewa" And Me.cboGesellschaft_Konto_intern = "AW/ _
Treuhand Lewa" Then
txtBetrag_MwSt.Text = ""
txtBetrag_MwSt.Enabled = False
txtBetrag_MwSt.BackColor = 14737632
cboGesellschaft_Konto.Text = ""
MsgBox "Sie haben die gleichen Konten ausgewählt!"
Else
If LCase(Right(cboGesellschaft_Konto.Text, 4)) = "euro" And LCase(Right( _
cboGesellschaft_Konto_intern.Text, 4)) = "lewa" _
Or LCase(Right(cboGesellschaft_Konto.Text, 4)) = "lewa" And LCase(Right( _
cboGesellschaft_Konto_intern.Text, 4)) = "euro" Then
txtBetrag_MwSt.Text = ""
txtBetrag_MwSt.Enabled = False
txtBetrag_MwSt.BackColor = 14737632
cboGesellschaft_Konto.Text = ""
MsgBox "Sie haben Konten unterschiedlicher Wärung ausgewählt!"
Else
If LCase(Right(cboGesellschaft_Konto.Text, 4)) = "euro" And LCase(Right( _
cboGesellschaft_Konto_intern.Text, 4)) = "euro" _
Or LCase(Right(cboGesellschaft_Konto.Text, 4)) = "euro" And LCase(Right( _
cboGesellschaft_Konto_intern.Text, 4)) = "euro" Then
txtBetrag_MwSt.Text = ""
txtBetrag_MwSt.Enabled = False
txtBetrag_MwSt.BackColor = 14737632
Else
If Me.cboGesellschaft_Konto = "AS/Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "AW/Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "AW/Allgemeines Euro" _
Or Me.cboGesellschaft_Konto = "AW/Treuhand Lewa" _
Or Me.cboGesellschaft_Konto = "AW/Treuhand Euro" _
Or Me.cboGesellschaft_Konto_intern = "AS/Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto_intern = "AW/Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto_intern = "AW/Allgemeines Euro" _
Or Me.cboGesellschaft_Konto_intern = "AW/Treuhand Lewa" _
Or Me.cboGesellschaft_Konto_intern = "AW/Treuhand Euro" Then
txtBetrag_MwSt.Text = ""
txtBetrag_MwSt.Enabled = False
txtBetrag_MwSt.BackColor = 14737632
Else
txtBetrag_MwSt.Enabled = True
txtBetrag_MwSt.BackColor = &H80000005
End If
End If
End If
End If
End Sub
Private Sub cboGesellschaft_Konto_intern_Change()
If Me.cboGesellschaft_Konto = "DA/Allgemeines Lewa" And Me.cboGesellschaft_Konto_intern = "DA/ _
Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "DA/Kontokorrent Lewa" And Me.cboGesellschaft_Konto_intern = "DA/ _
Kontokorrent Lewa" _
Or Me.cboGesellschaft_Konto = "DA/Treuhand Lewa" And Me.cboGesellschaft_Konto_intern = "DA/ _
Treuhand Lewa" _
Or Me.cboGesellschaft_Konto = "AS/Allgemeines Lewa" And Me.cboGesellschaft_Konto_intern = "AS/ _
Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "LB/Allgemeines Lewa" And Me.cboGesellschaft_Konto_intern = "LB/ _
Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "LHB/Allgemeines Lewa" And Me.cboGesellschaft_Konto_intern = "LHB/ _
Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "AW/Allgemeines Lewa" And Me.cboGesellschaft_Konto_intern = "AW/ _
Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "AW/Treuhand Lewa" And Me.cboGesellschaft_Konto_intern = "AW/ _
Treuhand Lewa" Then
txtBetrag_MwSt.Text = ""
txtBetrag_MwSt.Enabled = False
txtBetrag_MwSt.BackColor = 14737632
cboGesellschaft_Konto_intern.Text = ""
MsgBox "Sie haben die gleichen Konten ausgewählt!"
Else
If LCase(Right(cboGesellschaft_Konto.Text, 4)) = "euro" And LCase(Right( _
cboGesellschaft_Konto_intern.Text, 4)) = "lewa" _
Or LCase(Right(cboGesellschaft_Konto.Text, 4)) = "lewa" And LCase(Right( _
cboGesellschaft_Konto_intern.Text, 4)) = "euro" Then
txtBetrag_MwSt.Text = ""
txtBetrag_MwSt.Enabled = False
txtBetrag_MwSt.BackColor = 14737632
cboGesellschaft_Konto_intern.Text = ""
MsgBox "Sie haben Konten unterschiedlicher Wärung ausgewählt!"
Else
If LCase(Right(cboGesellschaft_Konto.Text, 4)) = "euro" And LCase(Right( _
cboGesellschaft_Konto_intern.Text, 4)) = "euro" _
Or LCase(Right(cboGesellschaft_Konto.Text, 4)) = "euro" And LCase(Right( _
cboGesellschaft_Konto_intern.Text, 4)) = "euro" Then
txtBetrag_MwSt.Text = ""
txtBetrag_MwSt.Enabled = False
txtBetrag_MwSt.BackColor = 14737632
Else
If Me.cboGesellschaft_Konto_intern = "AS/Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto_intern = "AW/Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto_intern = "AW/Allgemeines Euro" _
Or Me.cboGesellschaft_Konto_intern = "AW/Treuhand Lewa" _
Or Me.cboGesellschaft_Konto_intern = "AW/Treuhand Euro" _
Or Me.cboGesellschaft_Konto = "AS/Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "AW/Allgemeines Lewa" _
Or Me.cboGesellschaft_Konto = "AW/Allgemeines Euro" _
Or Me.cboGesellschaft_Konto = "AW/Treuhand Lewa" _
Or Me.cboGesellschaft_Konto = "AW/Treuhand Euro" Then
txtBetrag_MwSt.Text = ""
txtBetrag_MwSt.Enabled = False
txtBetrag_MwSt.BackColor = 14737632
Else
txtBetrag_MwSt.Enabled = True
txtBetrag_MwSt.BackColor = &H80000005
End If
End If
End If
End If
End Sub