الكود بعد التعديل
Private Sub CommandButton1_Click()
Dim ws As Worksheet
Set ws = Worksheets("Penalty")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 2) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.txtDate.Value) = "" Or Trim(Me.txtBadge.Value) = "" Then
Me.txtDate.SetFocus
MsgBox "Please enter a number and badge"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 2).Value = Me.txtDate.Value
ws.Cells(iRow, 3).Value = Me.txtBadge.Value
ws.Cells(iRow, 4).Value = Me.txtBank.Value
ws.Cells(iRow, 5).Value = Me.txtTransactionType.Value
ws.Cells(iRow, 6).Value = Me.txtAmountSR.Value
ws.Cells(iRow, 7).Value = Me.txtRemarks.Value
'clear the data
Me.txtDate.Value = ""
Me.txtBadge.Value = ""
Me.txtBank.Value = ""
Me.txtTransactionType.Value = ""
Me.txtAmountSR.Value = ""
Me.txtRemarks.Value = ""
Me.txtDate.SetFocus
End Sub
Monthly-kemas.rar