Private Sub ReceivePoLineBt_Click()
msg = "Warning, Ready to receive Line?"
Style = vbYesNo + vbCritical
Title = "Confirm information!"
response = MsgBox(msg, Style, Title)
If response = vbYes Then
'Create variable to obtain number of open records open in the PO.
Dim recordcounttxt As Integer
Dim ReportPrint As String
Dim LabelPrint As String
recordcounttxt = 0
recordcounttxt = Form_FrmSubPoGoodsReceipts.recordcounttxt.Value
If (recordcounttxt = 1) Then
'if record count equals one, execute the lines below
If (Me.discrepancybox = True) Then
'if record equals one, and it has a discrepany execute lines below
CurrentDb.Execute "UPDATE PurchaseOrderDetailTable SET StocklineStatusID_FK = 3 " & " WHERE [IncomingGoodsID]=" & Me!IncomingGoodsID_FK & ""
Me.StocklineStatus.Value = 3
CurrentDb.Execute "UPDATE PurchaseOrderTable SET PurchaseOrderStatusID_FK = 2" & " WHERE [PurchaseOrderID]=" & Me!PurchaseOrderID_FK & ""
Form_FrmSubGoodReceipts.Stockline_FK = Me.Stockline
Form_FrmSubGoodReceipts.SupplierID_FK = Form_FrmPoGoodReceipts.SupplierID_FK.Value
Form_FrmSubGoodReceipts.Buyer = Form_FrmPoGoodReceipts.Fname.Value
Form_FrmSubGoodReceipts.SupplierPackingList = Me.Packinglisttxt.Value
Form_FrmSubGoodReceipts.PurchaseOrderID_FK = Me.PurchaseOrderID_FK.Value
Form_FrmSubGoodReceipts.AmountToPaid = Me.PoCost.Value
Form_FrmSubGoodReceipts.QtyReceived = Me.PoQty.Value
Form_FrmSubGoodReceipts.GrStatus = 3
Me.POReceivedDate = Now()
MsgBox "Order received complete!"
Form_FrmSubGoodReceipts.DateReceived = Now()
Form_FrmSubIOHReceiving.Requery
'ReportPrint = "RpSubFrmGrDet"
'LabelPrint = "RpPrintLabel"
DoCmd.OpenReport "RpSubFrmGrDet", , , "[Stockline]=" & Me.Stockline
DoCmd.OpenReport "RpPrintLabel", , , "[Stockline]=" & Me.Stockline
DoCmd.Close
msg = "Order received complete, Would you like to receive another Purchase order?"
Style = vbYesNo + vbCritical
Title = "Receive another PO"
response = MsgBox(msg, Style, Title)
If response = vbYes Then
DoCmd.Close
DoCmd.OpenForm "FrmSearchPoReceive"
Exit Sub
End If
If response = vbNo Then
DoCmd.Close
DoCmd.OpenForm "Xappmenu"
Exit Sub
End If
Else
'if records equals one, no dsicrepancy execute line below
CurrentDb.Execute "UPDATE PurchaseOrderDetailTable SET StocklineStatusID_FK = 2 " & " WHERE [IncomingGoodsID]=" & Me!IncomingGoodsID_FK & ""
Me.StocklineStatus.Value = 2
CurrentDb.Execute "UPDATE PurchaseOrderTable SET PurchaseOrderStatusID_FK = 2" & " WHERE [PurchaseOrderID]=" & Me!PurchaseOrderID_FK & ""
Form_FrmSubGoodReceipts.Stockline_FK = Me.Stockline
Form_FrmSubGoodReceipts.SupplierID_FK = Form_FrmPoGoodReceipts.SupplierID_FK.Value
Form_FrmSubGoodReceipts.Buyer = Form_FrmPoGoodReceipts.Fname.Value
Form_FrmSubGoodReceipts.SupplierPackingList = Me.Packinglisttxt.Value
Form_FrmSubGoodReceipts.PurchaseOrderID_FK = Me.PurchaseOrderID_FK.Value
Form_FrmSubGoodReceipts.AmountToPaid = Me.PoCost.Value
Form_FrmSubGoodReceipts.QtyReceived = Me.PoQty.Value
Form_FrmSubGoodReceipts.GrStatus = 1
Me.POReceivedDate = Now()
MsgBox "Order received complete!"
Form_FrmSubGoodReceipts.DateReceived = Now()
Form_FrmSubIOHReceiving.Requery
'ReportPrint = "RpSubFrmGrDet"
'LabelPrint = "RpPrintLabel"
DoCmd.OpenReport "RpSubFrmGrDet", , , "[Stockline]=" & Me.Stockline
DoCmd.OpenReport "RpPrintLabel", , , "[Stockline]=" & Me.Stockline
DoCmd.Close
msg = "Order receive complete, Would you like to receive another Purchase order?"
Style = vbYesNo + vbCritical
Title = "Receive another PO"
response = MsgBox(msg, Style, Title)
If response = vbYes Then
DoCmd.Close
DoCmd.OpenForm "FrmSearchPoReceive"
Exit Sub
End If
If response = vbNo Then
DoCmd.Close
DoCmd.OpenForm "Xappmenu"
Exit Sub
End If
End If
Else
'If purchase order has more than one line, execute below instructions and no discrepancies and check discrepancy
If (Me.discrepancybox = True) Then
'if discrepancy, execute lines below
CurrentDb.Execute "UPDATE PurchaseOrderDetailTable SET StocklineStatusID_FK = 3 " & " WHERE [IncomingGoodsID]=" & Me!IncomingGoodsID_FK & ""
Me.StocklineStatus.Value = 3
Form_FrmSubGoodReceipts.Stockline_FK = Me.Stockline
Form_FrmSubGoodReceipts.SupplierID_FK = Form_FrmPoGoodReceipts.SupplierID_FK.Value
Form_FrmSubGoodReceipts.Buyer = Form_FrmPoGoodReceipts.Fname.Value
Form_FrmSubGoodReceipts.SupplierPackingList = Me.Packinglisttxt.Value
Form_FrmSubGoodReceipts.PurchaseOrderID_FK = Me.PurchaseOrderID_FK.Value
Form_FrmSubGoodReceipts.AmountToPaid = Me.PoCost.Value
Form_FrmSubGoodReceipts.QtyReceived = Me.PoQty.Value
Form_FrmSubGoodReceipts.GrStatus = 3
Form_FrmSubGoodReceipts.DateReceived = Now()
Form_FrmSubPoGoodsReceipts.Requery
Form_FrmSubIOHReceiving.Requery
DoCmd.OpenReport "RpSubFrmGrDet", , , "[Stockline]=" & Me.Stockline
DoCmd.OpenReport "RpPrintLabel", , , "[Stockline]=" & Me.Stockline
Me.ContinueGrBt.Enabled = True
Form_FrmSubPoGoodsReceipts.IncomingGoodsID.Enabled = True
Me.ContinueGrBt.Enabled = True
Form_FrmPoGoodReceipts.SetFocus
Form_FrmPoGoodReceipts.FrmSubPoGoodsReceipts.SetFocus
Form_FrmSubPoGoodsReceipts.IncomingGoodsID.SetFocus
Form_FrmSubIOHReceiving.Refresh
Call invisible
Form_FrmPoGoodReceipts.FrmSubIOHReceiving.Visible = False
Exit Sub
Else
'if no discrepancy execute lines below
CurrentDb.Execute "UPDATE PurchaseOrderDetailTable SET StocklineStatusID_FK = 2 " & " WHERE [IncomingGoodsID]=" & Me!IncomingGoodsID_FK & ""
Me.StocklineStatus.Value = 2
Form_FrmSubGoodReceipts.Stockline_FK = Me.Stockline
Form_FrmSubGoodReceipts.SupplierID_FK = Form_FrmPoGoodReceipts.SupplierID_FK.Value
Form_FrmSubGoodReceipts.Buyer = Form_FrmPoGoodReceipts.Fname.Value
Form_FrmSubGoodReceipts.SupplierPackingList = Me.Packinglisttxt.Value
Form_FrmSubGoodReceipts.PurchaseOrderID_FK = Me.PurchaseOrderID_FK.Value
Form_FrmSubGoodReceipts.AmountToPaid = Me.PoCost.Value
Form_FrmSubGoodReceipts.QtyReceived = Me.PoQty.Value
Form_FrmSubGoodReceipts.GrStatus = 1
Form_FrmSubGoodReceipts.DateReceived = Now()
Form_FrmSubPoGoodsReceipts.Requery
Form_FrmSubIOHReceiving.Requery
DoCmd.OpenReport "RpSubFrmGrDet", , , "[Stockline]=" & Me.Stockline
DoCmd.OpenReport "RpPrintLabel", , , "[Stockline]=" & Me.Stockline
Form_FrmSubPoGoodsReceipts.IncomingGoodsID.Enabled = True
Me.ContinueGrBt.Enabled = True
Form_FrmPoGoodReceipts.SetFocus
Form_FrmPoGoodReceipts.FrmSubPoGoodsReceipts.SetFocus
Form_FrmSubPoGoodsReceipts.IncomingGoodsID.SetFocus
Form_FrmSubIOHReceiving.Refresh
Call invisible
Form_FrmPoGoodReceipts.FrmSubIOHReceiving.Visible = False
Exit Sub
End If
End If
Exit Sub
End If
If response = vbNo Then
Me.Undo
Exit Sub
End If
End Sub