I am trying to get the below statement work in VBA, but I always get the following error message: "Else without if"
Hope that someone help me ...
Hope that someone help me ...
Code:
If (Qty < SolderieQty Or Qty = SolderieQty) Then
If (Qty < sumq) Then
MsgBox "check the Quantity. qty < sumq"
Me.q1.SetFocus
End If
If (Qty > sumq) Then
MsgBox "check the Quantity. qty > sumq"
Me.q1.SetFocus
End If
If (Qty = sumq) Then
'ADD the record into SendDetails table
If ((Not IsNull(Article)) And (Not IsNull(sentdate)) And (Not IsNull(SendFrom)) And (Not IsNull(SendTo))) Then
MsgBox "first"
If (CheckIfSent(CLng(Forms![Transfer]!Article), CDate(Forms![Transfer]!send_Date), CStr(Forms![Transfer]!SendFrom), CStr(Forms![Transfer]!SendTo))) Then
MsgBox "you have sent this article before to the same location"
Forms![Transfer]![Article].SetFocus
MsgBox "aaaa"
Else
If (CheckIfSent(CLng(Forms![Transfer]!Article), CDate(Forms![Transfer]!send_Date), CStr(Forms![Transfer]!SendFrom), CStr(Forms![Transfer]!SendTo)) = False) Then
MsgBox "bbbb"
InsertIntoSendDetails CDate(sentdate), CStr(SendFrom), CStr(SendTo), CLng(Article), CLng(Qty), CLng(q1), CLng(q2), _
CLng(q3), CLng(q4), CLng(q5), CLng(q6), CLng(q7), CLng(q8), CLng(q9), CLng(q10), CLng(q11), CLng(q12), CLng(q13), CLng(q14) 'ADD TO WearHouseStock (st_house_qi) and MINUS FROM SolderieStock (st_sol_qi)
Me.st_q1.Value = (Nz(Me.st_q1.Value, 0) - Nz(Me.q1.Value, 0))
Me.st_relax_q1.Value = (Nz(Me.st_relax_q1.Value, 0) + Nz(Me.q1.Value, 0))
Me.st_q2.Value = (Nz(Me.st_q2.Value, 0) - Nz(Me.q2.Value, 0))
Me.st_relax_q2.Value = (Nz(Me.st_relax_q2.Value, 0) + Nz(Me.q2.Value, 0))
Me.st_q3.Value = (Nz(Me.st_q3.Value, 0) - Nz(Me.q3.Value, 0))
Me.st_relax_q3.Value = (Nz(Me.st_relax_q3.Value, 0) + Nz(Me.q3.Value, 0))
Me.st_q4.Value = (Nz(Me.st_q4.Value, 0) - Nz(Me.q4.Value, 0))
Me.st_relax_q4.Value = (Nz(Me.st_relax_q4.Value, 0) + Nz(Me.q4.Value, 0))
Me.st_q5.Value = (Nz(Me.st_q5.Value, 0) - Nz(Me.q5.Value, 0))
Me.st_relax_q5.Value = (Nz(Me.st_relax_q5.Value, 0) + Nz(Me.q5.Value, 0))
Me.st_q6.Value = (Nz(Me.st_q6.Value, 0) - Nz(Me.q6.Value, 0))
Me.st_relax_q6.Value = (Nz(Me.st_relax_q6.Value, 0) + Nz(Me.q6.Value, 0))
Me.st_q7.Value = (Nz(Me.st_q7.Value, 0) - Nz(Me.q7.Value, 0))
Me.st_relax_q7.Value = (Nz(Me.st_relax_q7.Value, 0) + Nz(Me.q7.Value, 0))
Me.st_q8.Value = (Nz(Me.st_q8.Value, 0) - Nz(Me.q8.Value, 0))
Me.st_relax_q8.Value = (Nz(Me.st_relax_q8.Value, 0) + Nz(Me.q8.Value, 0))
Me.st_q9.Value = (Nz(Me.st_q9.Value, 0) - Nz(Me.q9.Value, 0))
Me.st_relax_q9.Value = (Nz(Me.st_relax_q9.Value, 0) + Nz(Me.q9.Value, 0))
Me.st_q10.Value = (Nz(Me.st_q10.Value, 0) - Nz(Me.q10.Value, 0))
Me.st_relax_q10.Value = (Nz(Me.st_relax_q10.Value, 0) + Nz(Me.q10.Value, 0))
Me.st_q11.Value = (Nz(Me.st_q11.Value, 0) - Nz(Me.q11.Value, 0))
Me.st_relax_q11.Value = (Nz(Me.st_relax_q11.Value, 0) + Nz(Me.q11.Value, 0))
Me.st_q12.Value = (Nz(Me.st_q12.Value, 0) - Nz(Me.q12.Value, 0))
Me.st_relax_q12.Value = (Nz(Me.st_relax_q12.Value, 0) + Nz(Me.q12.Value, 0))
Me.st_q13.Value = (Nz(Me.st_q13.Value, 0) - Nz(Me.q13.Value, 0))
Me.st_relax_q13.Value = (Nz(Me.st_relax_q13.Value, 0) + Nz(Me.q13.Value, 0))
Me.st_q14.Value = (Nz(Me.st_q14.Value, 0) - Nz(Me.q14.Value, 0))
Me.st_relax_q14.Value = (Nz(Me.st_relax_q14.Value, 0) + Nz(Me.q14.Value, 0))
Me.SolderieStock.Value = (Nz(Me.SolderieStock.Value, 0) - Me.Qty.Value)
Me.RelaxStock.Value = (Nz(Me.RelaxStock.Value, 0) + Me.Qty.Value)
End If
End If
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Else
MsgBox "Qty entered more than the solderie stock quantity"
Me.Qty.SetFocus
End If
Comment