ISO9000Man
Technical User
I am working on coding an update query in a form that will update a table which tracks our raw material receiving and issue. Can someone look over this newby's code and point me in the right direction?
I have a form [frmMaterialIssue] with two subforms. [subform1] shows material available after an item is entered into [Item].
[subform2] is used for recording how much material from each Lot is used for the Workorder being started.
After I select the pounds of material I am using and the Lot#, I enter it into [subform2]. There could be more than one record for each work order started.
Upon saving the main form I want to update the available stock for each "Lot" in the underlying table for [subform1]. If the available stock is then "0" I also want to insert a check in [ysnClosed] showing all the material for that Lot# has been used.
-----------Structure------------------------------------------------------------------
Main Form::
[frmMaterialIssue]
-[Item]............Item# of material being issued
-[WO]............Workorder being started
-[subform1] ....shows available stock along with Lot#
-[subform2] ....used to record stock issued for each workorder
[tblHeat] ...data entered when material is received from supplier. This is source of [subform1].
fields:: [intBPCLot]..........Lot# given to the material when it arrives from supplier
[intPoundsAvail]....amount of stock available in this lot
[ysnClosed]...........When this is checked it shows all product for this Lot# has been used.
[subform2]...issued stock is recorded here for each workorder. Data is stored in [tblMaterialIssuedStock] including workorder#.
fields:: [intBPCLot]....Lot# of issued material
[intPoundsIssued]....amount of stock issued from each Lot#
---------First Draft of code showing what I want to do-----------------------------------
Dim strSQL As String
strSQL = "UPDATE tblHeat SET intPoundsAvail = (intPoundsAvail - [tblMaterialIssueStock].[intPoundsIssued]),_"
WHERE " & intBPCLot = [tblMaterialIssuedStock].[intBPCLot] & "" & " And Me.strWO = "&[tblMaterialIssueStock].[WO] & " '"
If intPoundsAvail = "<1" Then
ysnClosed.Value = "Yes"
CurrentDb.Execute strSQL, 128
End If
I have a form [frmMaterialIssue] with two subforms. [subform1] shows material available after an item is entered into [Item].
[subform2] is used for recording how much material from each Lot is used for the Workorder being started.
After I select the pounds of material I am using and the Lot#, I enter it into [subform2]. There could be more than one record for each work order started.
Upon saving the main form I want to update the available stock for each "Lot" in the underlying table for [subform1]. If the available stock is then "0" I also want to insert a check in [ysnClosed] showing all the material for that Lot# has been used.
-----------Structure------------------------------------------------------------------
Main Form::
[frmMaterialIssue]
-[Item]............Item# of material being issued
-[WO]............Workorder being started
-[subform1] ....shows available stock along with Lot#
-[subform2] ....used to record stock issued for each workorder
[tblHeat] ...data entered when material is received from supplier. This is source of [subform1].
fields:: [intBPCLot]..........Lot# given to the material when it arrives from supplier
[intPoundsAvail]....amount of stock available in this lot
[ysnClosed]...........When this is checked it shows all product for this Lot# has been used.
[subform2]...issued stock is recorded here for each workorder. Data is stored in [tblMaterialIssuedStock] including workorder#.
fields:: [intBPCLot]....Lot# of issued material
[intPoundsIssued]....amount of stock issued from each Lot#
---------First Draft of code showing what I want to do-----------------------------------
Dim strSQL As String
strSQL = "UPDATE tblHeat SET intPoundsAvail = (intPoundsAvail - [tblMaterialIssueStock].[intPoundsIssued]),_"
WHERE " & intBPCLot = [tblMaterialIssuedStock].[intBPCLot] & "" & " And Me.strWO = "&[tblMaterialIssueStock].[WO] & " '"
If intPoundsAvail = "<1" Then
ysnClosed.Value = "Yes"
CurrentDb.Execute strSQL, 128
End If