Private Sub CommandButton1_Click()
Dim sht As Worksheet, sht1 As Worksheet, lastrow As Long
''''''''Validation''''''''
If Me.TextBox1.Value = "" Then
MsgBox "Please enter a correct location", vbCritical
Exit Sub
End If
If VBA.IsNumeric(Me.TextBox2.Value) = False Then
MsgBox "Please enter a correct GRN", vbCritical
Exit Sub
End If
If Me.TextBox3.Value = "" Then
MsgBox "Please enter a correct item code", vbCritical
Exit Sub
End If
If Me.TextBox6.Value = "" Then
MsgBox "Please enter transaction date", vbCritical
Exit Sub
End If
If Me.TextBox6.Value = "" Then
MsgBox "Please enter quantity", vbCritical
Exit Sub
End If
If Me.OptionButton1.Value = False And Me.OptionButton2.Value = False And Me.OptionButton3.Value = False And Me.OptionButton4.Value = False Then
MsgBox "Please select status", vbCritical
Exit Sub
End If
''''''''End of Validation''''''''
Set sht = ThisWorkbook.Sheets("WH STOCK")
lastrow = sht.Range("a" & Rows.Count).End(xlUp).Row + 1
''''sh.unprotect code - if ever I needed''''
With sht
.Range("A" & lastrow).Value = Me.TextBox1.Value
.Range("B" & lastrow).Value = Me.TextBox2.Value
.Range("C" & lastrow).Value = Me.TextBox3.Value
.Range("D" & lastrow).Value = Me.TextBox4.Value
.Range("G" & lastrow).Value = Me.TextBox5.Value
.Range("H" & lastrow).Value = "Y"
.Range("I" & lastrow).Value = Me.TextBox6.Value
.Range("K" & lastrow).Value = Me.TextBox7.Value
.Range("L" & lastrow).Value = Me.TextBox10.Value
.Range("M" & lastrow).Value = Me.TextBox11.Value
.Range("N" & lastrow).Value = Me.TextBox13.Value
.Range("O" & lastrow).Value = Me.TextBox14.Value
.Range("P" & lastrow).Value = Me.TextBox15.Value
.Range("Q" & lastrow).Value = Me.TextBox16.Value
.Range("R" & lastrow).Value = Me.TextBox17.Value
.Range("G" & lastrow).NoteText Text:=add_frm.TextBox18.Value
''''sh.protect code - if ever I needed''''
End With
sht.Activate
If Me.OptionButton1.Value = True Then sht.Range("J" & lastrow).Value = "APPROVED"
If Me.OptionButton2.Value = True Then sht.Range("J" & lastrow).Value = "ON HOLD"
If Me.OptionButton3.Value = True Then sht.Range("J" & lastrow).Value = "REJECT"
If Me.OptionButton4.Value = True Then sht.Range("J" & lastrow).Value = "QUARANTINE"
Exit Sub
End Sub
Private Sub CommandButton2_Click()
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.TextBox6.Value = ""
Me.TextBox7.Value = ""
Me.TextBox10.Value = ""
Me.TextBox11.Value = ""
Me.TextBox13.Value = ""
Me.TextBox14.Value = ""
Me.TextBox15.Value = ""
Me.TextBox16.Value = ""
Me.TextBox17.Value = ""
Me.TextBox18.Value = ""
Me.OptionButton1.Value = False
Me.OptionButton2.Value = False
Me.OptionButton3.Value = False
Me.OptionButton4.Value = False
End Sub
Bookmarks