You are on page 1of 1

Private Sub cmdCustomer_Click()

Dim X As Integer
Dim nextrow As Range
On Error GoTo cmdCustomer_Click_Error
Set nextrow = Sheet6.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0)
For X = 1 To 4
If Me.Controls("Customer" & X).Value = "" Then
MsgBox "You must add Name ,Address ,City and State"
Exit Sub
End If
Next
If WorksheetFunction.CountIf(Sheet6.Range("C:C"), Me.Customer1.Value) > 0 Then
MsgBox "This customer already exists"
Exit Sub
End If
For X = 1 To 9
nextrow = Me.Controls("Customer" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
'clear
For X = 1 To 9
Me.Controls("Customer" & X).Value = ""
Next
On Error GoTo 0
Exit Sub
cmdCustomer_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdCusto
mer_Click of Form frmCustomer"
End Sub

You might also like