Option Compare Database Option Explicit '------------------------------------------------------------ ' CreateTransRecordOCO() ' ' DESC: After update of OCO_Form!Qty_Filled field, this function ' compares the Qty_Filled with the Qty_Ordered for verification. ' If verification is not passed, then the Qty_Filled field is not ' updated. If verification is passed then the Qty_Filled field is updated ' and a record is added to the Transaction_File table. ' ' INPUT: OCO_Form, OCO_Subform, Open_Customer_Order_Products table ' IMF table, ' OUTPUTS: Transaction_File table, Open_Customer_Order_Products!Qty_Filled field ' ' Written by Shawn McKenna '------------------------------------------------------------ Function CreateTransRecordOCO() Dim dbOCO As Database Dim rcdOCO, rcdTRANS, rcdIMF As Recordset Dim Prod_ID, CON, Qty_Ordered As Long Dim frm As Form Dim intReturn As Integer Set dbOCO = CurrentDb() Set frm = Forms!OCO_Form Set rcdOCO = dbOCO.OpenRecordset("Open_Customer_Order_Products") Set rcdIMF = dbOCO.OpenRecordset("IMF") Set rcdTRANS = dbOCO.OpenRecordset("Transaction_File") Prod_ID = frm!OCO_Subform!Prod_ID CON = frm!Customer_Order_Num While Not rcdOCO.EOF If rcdOCO![Prod_ID] = Prod_ID And rcdOCO![Customer_Order_Num] = CON Then Qty_Ordered = rcdOCO![Qty_Ordered] ' Get the Qty_Ordered Number ' the following if statement compares the Qty_Ordered with the Qty_Filled ' for verification. If Qty_Ordered is less than Qty_Filled then there is ' no updating and the function is exited. If Qty_Ordered is equal to ' Qty_Filled then a transaction record is added. If Qty_Filled is less than ' Qty_Ordered then the user has a choice of updating the record and adding a ' transaction record or exiting the function. If Qty_Ordered < frm!OCO_Subform!Qty_Filled Then MsgBox "You have filled more items than " & _ "the order has asked for. The " & _ "quantity ordered is " & Qty_Ordered & ".", _ vbExclamation, "Champion Sporting Goods" frm!OCO_Subform!Qty_Filled = Null Exit Function ElseIf Qty_Ordered > frm!OCO_Subform!Qty_Filled Then intReturn = MsgBox("You have filled less items than " & _ "the order has asked for. The " & _ "quantity ordered is " & Qty_Ordered & ". " & _ "Do you want to continue?", _ vbQuestion + vbYesNo, "Champion Sporting Goods") If intReturn = vbNo Then frm!OCO_Subform!Qty_Filled = Null Exit Function End If End If rcdTRANS.AddNew rcdTRANS![Transaction_Type] = rcdOCO![Transaction_Type] rcdTRANS![Origin] = frm!CO_Store_Source rcdTRANS![Destination] = frm!Customer_ID rcdTRANS![Trans_Date] = Date rcdTRANS![Trans_Time] = Time rcdTRANS![Product_Num] = Prod_ID ' These statements find the Cost_per_Unit in the IMF table ' equal to the Prod_ID on the OCO_Form While Not rcdIMF.EOF If rcdIMF![Product_Num] = Prod_ID Then rcdTRANS![Cost_per_Unit] = rcdIMF![Cost_per_Unit] End If rcdIMF.MoveNext Wend rcdTRANS![Qty_Ordered] = rcdOCO!Qty_Ordered rcdTRANS![Qty_Filled] = frm!OCO_Subform!Qty_Filled rcdTRANS.Update End If rcdOCO.MoveNext Wend End Function '------------------------------------------------------------ ' CreateTransRecordIVO() ' ' DESC: After update of OVO_Form!Qty_Filled field, this function ' compares the Qty_Filled with the Qty_Ordered for verification. ' If verification is not passed, then the Qty_Filled field is not ' updated. If verification is passed then the Qty_Filled field is updated ' and a record is added to the Transaction_File table. ' ' INPUT: IVO_Form, IVO_Subform, Open_Purchase_Order_Products table ' IMF table, ' OUTPUTS: Transaction_File table, Open_Purchase_Order_Products!Qty_Filled field ' ' Written by '------------------------------------------------------------ Function CreateTransRecordIVO() Dim dbIVO As Database Dim rcdIVO, rcdTRANS, rcdIMF As Recordset Dim Prod_Num, PON, Qty_Ordered As Long Dim frm As Form Dim intReturn As Integer Set dbIVO = CurrentDb() Set frm = Forms!IVO_Form Set rcdIVO = dbIVO.OpenRecordset("Open_Purchase_Order_Products") Set rcdIMF = dbIVO.OpenRecordset("IMF") Set rcdTRANS = dbIVO.OpenRecordset("Transaction_File") Prod_Num = frm!IVO_Subform!Prod_Num PON = frm!Purchase_Order_Num While Not rcdIVO.EOF If rcdIVO![Prod_Num] = Prod_Num And rcdIVO![Purchase_Order_Num] = PON Then Qty_Ordered = rcdIVO![Qty_Ordered] ' Get the Qty_Ordered Number ' the following if statement compares the Qty_Ordered with the Qty_Filled ' for verification. If Qty_Ordered is less than Qty_Filled then there is ' no updating and the function is exited. If Qty_Ordered is equal to ' Qty_Filled then a transaction record is added. If Qty_Filled is less than ' Qty_Ordered then the user has a choice of updating the record and adding a ' transaction record or exiting the function. If Qty_Ordered < frm!IVO_Subform!Qty_Filled Then MsgBox "You have filled more items than " & _ "the order has asked for. The " & _ "quantity ordered is " & Qty_Ordered & ".", _ vbExclamation, "Champion Sporting Goods" frm!IVO_Subform!Qty_Filled = Null Exit Function ElseIf Qty_Ordered > frm!IVO_Subform!Qty_Filled Then intReturn = MsgBox("You have filled less items than " & _ "the order has asked for. The " & _ "quantity ordered is " & Qty_Ordered & ". " & _ "Do you want to continue?", _ vbQuestion + vbYesNo, "Champion Sporting Goods") If intReturn = vbNo Then frm!IVO_Subform!Qty_Filled = Null Exit Function End If End If rcdTRANS.AddNew rcdTRANS![Transaction_Type] = rcdIVO![Transaction_Type] rcdTRANS![Origin] = frm!Vendor_ID rcdTRANS![Destination] = frm!PO_Store_Destination rcdTRANS![Trans_Date] = Date rcdTRANS![Trans_Time] = Time rcdTRANS![Product_Num] = Prod_Num ' These statements find the Cost_per_Unit in the IMF table ' equal to the Prod_ID on the OCO_Form While Not rcdIMF.EOF If rcdIMF![Product_Num] = Prod_Num Then rcdTRANS![Cost_per_Unit] = rcdIMF![Cost_per_Unit] End If rcdIMF.MoveNext Wend rcdTRANS![Qty_Ordered] = rcdIVO!Qty_Ordered rcdTRANS![Qty_Filled] = frm!IVO_Subform!Qty_Filled rcdTRANS.Update End If rcdIVO.MoveNext Wend End Function '------------------------------------------------------------ ' CreateTransRecordOIT() ' ' DESC: After update of OIT_Form!Qty_Filled field, this function ' compares the Qty_Filled with the Qty_Ordered for verification. ' If verification is not passed, then the Qty_Filled field is not ' updated. If verification is passed then the Qty_Filled field is updated ' and a record is added to the Transaction_File table. ' ' INPUT: OIT_Form, OIT_Subform, Open_Trans_Order_Products table ' IMF table, ' OUTPUTS: Transaction_File table, Open_Trans_Order_Products!Qty_Filled field ' ' Written by '------------------------------------------------------------ Function CreateTransRecordOIT() Dim dbOIT As Database Dim rcdOIT, rcdTRANS, rcdIMF As Recordset Dim Prod_Num, TON, Qty_Ordered As Long Dim frm As Form Dim intReturn As Integer Set dbOIT = CurrentDb() Set frm = Forms!OIT_Form Set rcdOIT = dbOIT.OpenRecordset("Open_Trans_Order_Products") Set rcdIMF = dbOIT.OpenRecordset("IMF") Set rcdTRANS = dbOIT.OpenRecordset("Transaction_File") Prod_Num = frm!OIT_Subform!Product_Num TON = frm!Trans_Order_Num While Not rcdOIT.EOF If rcdOIT![Product_Num] = Prod_Num And rcdOIT![Trans_Order_Num] = TON Then Qty_Ordered = rcdOIT![Qty_Ordered] ' Get the Qty_Ordered Number ' the following if statement compares the Qty_Ordered with the Qty_Filled ' for verification. If Qty_Ordered is less than Qty_Filled then there is ' no updating and the function is exited. If Qty_Ordered is equal to ' Qty_Filled then a transaction record is added. If Qty_Filled is less than ' Qty_Ordered then the user has a choice of updating the record and adding a ' transaction record or exiting the function. If Qty_Ordered < frm!OIT_Subform!Qty_Filled Then MsgBox "You have filled more items than " & _ "the order has asked for. The " & _ "quantity ordered is " & Qty_Ordered & ".", _ vbExclamation, "Champion Sporting Goods" frm!OIT_Subform!Qty_Filled = Null Exit Function ElseIf Qty_Ordered > frm!OIT_Subform!Qty_Filled Then intReturn = MsgBox("You have filled less items than " & _ "the order has asked for. The " & _ "quantity ordered is " & Qty_Ordered & ". " & _ "Do you want to continue?", _ vbQuestion + vbYesNo, "Champion Sporting Goods") If intReturn = vbNo Then frm!OIT_Subform!Qty_Filled = Null Exit Function End If End If rcdTRANS.AddNew rcdTRANS![Transaction_Type] = "OT" rcdTRANS![Origin] = frm!TO_Origin rcdTRANS![Destination] = frm!TO_Destination rcdTRANS![Trans_Date] = Date rcdTRANS![Trans_Time] = Time rcdTRANS![Product_Num] = Prod_Num ' These statements find the Cost_per_Unit in the IMF table ' equal to the Prod_ID on the OCO_Form While Not rcdIMF.EOF If rcdIMF![Product_Num] = Prod_Num Then rcdTRANS![Cost_per_Unit] = rcdIMF![Cost_per_Unit] End If rcdIMF.MoveNext Wend rcdTRANS![Qty_Ordered] = rcdOIT!Qty_Ordered rcdTRANS![Qty_Filled] = frm!OIT_Subform!Qty_Filled rcdTRANS.Update End If rcdOIT.MoveNext Wend End Function '------------------------------------------------------------ ' CreateTransRecordITO() ' ' DESC: After update of ITO_Form!Qty_Filled field, this function ' compares the Qty_Filled with the Qty_Ordered for verification. ' If verification is not passed, then the Qty_Filled field is not ' updated. If verification is passed then the Qty_Filled field is updated ' and a record is added to the Transaction_File table. ' ' INPUT: ITO_Form, ITO_Subform, Open_Trans_Order_Products table ' IMF table, ' OUTPUTS: Transaction_File table, Open_Trans_Order_Products!Qty_Filled field ' ' Written by '------------------------------------------------------------ Function CreateTransRecordITO() Dim dbITO As Database Dim rcdITO, rcdTRANS, rcdIMF As Recordset Dim Prod_Num, TON, Qty_Ordered As Long Dim frm As Form Dim intReturn As Integer Set dbITO = CurrentDb() Set frm = Forms!ITO_Form Set rcdITO = dbITO.OpenRecordset("Open_Trans_Order_Products") Set rcdIMF = dbITO.OpenRecordset("IMF") Set rcdTRANS = dbITO.OpenRecordset("Transaction_File") Prod_Num = frm!ITO_Subform!Product_Num TON = frm!Trans_Order_Num While Not rcdITO.EOF If rcdITO![Product_Num] = Prod_Num And rcdITO![Trans_Order_Num] = TON Then Qty_Ordered = rcdITO![Qty_Filled] ' Get the Qty_Ordered Number ' the following if statement compares the Qty_Ordered with the Qty_Filled ' for verification. If Qty_Ordered is less than Qty_Filled then there is ' no updating and the function is exited. If Qty_Ordered is equal to ' Qty_Filled then a transaction record is added. If Qty_Filled is less than ' Qty_Ordered then the user has a choice of updating the record and adding a ' transaction record or exiting the function. If Qty_Ordered < frm!ITO_Subform!Qty_Received Then MsgBox "You have filled more items than " & _ "the order has asked for. The " & _ "quantity filled from transfer is " & Qty_Ordered & ".", _ vbExclamation, "Champion Sporting Goods" frm!ITO_Subform!Qty_Received = Null Exit Function ElseIf Qty_Ordered > frm!ITO_Subform!Qty_Received Then intReturn = MsgBox("You have filled less items than " & _ "the order has asked for. The " & _ "quantity filled from transfer is " & Qty_Ordered & ". " & _ "Do you want to continue?", _ vbQuestion + vbYesNo, "Champion Sporting Goods") If intReturn = vbNo Then frm!ITO_Subform!Qty_Received = Null Exit Function End If End If rcdTRANS.AddNew rcdTRANS![Transaction_Type] = "IT" rcdTRANS![Origin] = frm!TO_Origin rcdTRANS![Destination] = frm!TO_Destination rcdTRANS![Trans_Date] = Date rcdTRANS![Trans_Time] = Time rcdTRANS![Product_Num] = Prod_Num ' These statements find the Cost_per_Unit in the IMF table ' equal to the Prod_ID on the OCO_Form While Not rcdIMF.EOF If rcdIMF![Product_Num] = Prod_Num Then rcdTRANS![Cost_per_Unit] = rcdIMF![Cost_per_Unit] End If rcdIMF.MoveNext Wend rcdTRANS![Qty_Ordered] = rcdITO!Qty_Filled rcdTRANS![Qty_Filled] = frm!ITO_Subform!Qty_Received rcdTRANS.Update End If rcdITO.MoveNext Wend End Function