CAn you please have a look on my code and tell me what is missing?
Code:
Private Sub cmdProcess_Click()
Dim z As Long
Dim UserName As Variant
Dim NameLookup As Variant
Dim strPName As String
Dim sFindIt As String
Dim iFoundPass As Integer
sFindIt = PayoutFrm.txtSerial.Value
If PayoutFrm.cboReceiptType.Value = "VOID" Then MsgBox ("Note all voids require the Casino Manager or Asst. Casino Manager's signature"), vbOKOnly, "Signature required"
On Error Resume Next
With Sheets("Security").Range("A1:A10")
iFoundPass = .Find(What:=PayoutFrm.cboUserName.Value, After:=.Cells(1, 1), LookIn:=xlValues, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Row
End With
On Error GoTo 0
If iFoundPass = 0 Then
SomethingWrong
Exit Sub
End If
If Sheets("Security").Cells(iFoundPass, 3) <> txtPassword Then
SomethingWrong
Exit Sub
End If
With Sheets("Log Sheet").Range("A:A").Cells.Find(What:=sFindIt, After:=Cells(10, 1), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False).Row
If Cells(, 28).Value > 0 Then _
MsgBox ("This bet has already been processed. Please select another bet"), vbCritical Or vbOKOnly
If Cells(, 28).Value > 0 Then Exit Sub
If PayoutFrm.cboReceiptType.Value = "WINNER" And Sheets("Log Sheet").Cells(, 22).Value <> "Winner" Then _
MsgBox ("This bet is not a winning bet"), vbCritical Or vbOKOnly
If PayoutFrm.cboReceiptType.Value = "WINNER" And Sheets("Log Sheet").Cells(, 22).Value <> "Winner" Then Exit Sub
End With
With PayoutFrm
If .txtSerial = "" Then
MsgBox "Please input a serial number", vbCritical Or vbOKOnly
If .cboReceiptType = "" Then Exit Sub
End If
If .cboUserName = "" Then
MsgBox "Please select a user before proceeding", vbCritical Or vbOKOnly
If .cboUserName = "" Then Exit Sub
End If
If .cboReceiptType = "" Then
MsgBox "Please select a receipt type before proceeding", vbCritical Or vbOKOnly
If .cboReceiptType = "" Then Exit Sub
End If
End With
If PayoutFrm.cboReceiptType.Value = "WINNER" And Sheets("Log Sheet").Cells(, 22).Value = "" Then MsgBox ("Please enter the game result on the log sheet before proceeding")
If PayoutFrm.cboReceiptType.Value = "WINNER" And Sheets("Log Sheet").Cells(, 22).Value = "" Then Exit Sub
strPName = Application.ActivePrinter ' Gets default printer name
'Set NameLookup = Sheets("Menu").Range("K4:K12")
'On Error Resume Next
'Err.Clear
'UserName = Application.WorksheetFunction.VLookup(cboUserName.Text, NameLookup, 2, False)
Application.ScreenUpdating = False
PrintFrm.Show
Sheets("Audit Log").Visible = True
Sheets("Audit Log").Select
ActiveSheet.Unprotect Password:="miami"
With ActiveSheet.[A2:D501]
For z = .Rows.Count To 1 Step -1
If .Cells(z, 1) & .Cells(z, 2) & .Cells(z, 3) & .Cells(z, 4) <> "" Then Exit For
Next
.Cells(z + 1, 1) = Now()
.Cells(z + 1, 2) = cboUserName.Text
.Cells(z + 1, 3) = UserName
.Cells(z + 1, 4) = cboReceiptType.Value & "- Serial# " & txtSerial.Value
End With
Sheets("Log Sheet").Visible = True
Sheets("Log Sheet").Select
With ActiveSheet
.Unprotect Password:="miami"
If PayoutFrm.cboReceiptType.Value = "VOID" Then Cells(, 28).Value = "VOID"
If PayoutFrm.cboReceiptType.Value = "WINNER" Then Cells(, 28).Value = "PAID"
If PayoutFrm.cboReceiptType.Value = "REFUND" Then Cells(, 28).Value = "REFUNDED"
.Protect Password:="miami"
.EnableSelection = xlNoSelection
End With
Unload Me
Application.ScreenUpdating = True
End Sub