Gruppe
Dialog
Problem
Es soll geprüft werden, ob die Kunden-Nr. schon vorhanden ist. Wenn nein, wird der Datensatz eingetragen.
ClassModule: frmKunden
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdEintragen_Click()
Dim iRow As Integer
If IsError(Application.Match(txtNo.Text, Columns(1), 0)) Then
iRow = WorksheetFunction.CountA(Columns(1)) + 1
Cells(iRow, 1).Value = txtNo.Text
If optHerr.Value Then
Cells(iRow, 2).Value = "Herr"
Else
Cells(iRow, 2).Value = "Frau"
End If
Cells(iRow, 3).Value = txtNachname.Text
Cells(iRow, 4).Value = txtVorname.Text
Else
MsgBox "Kundennummer ist bereits vorhanden!"
With txtNo
.SetFocus
.SelStart = 0
.SelLength = .TextLength
End With
End If
End Sub
StandardModule: Modul1
Sub CallForm()
frmKunden.Show
End Sub