S
stfcTerryA
Hi
I'm trying to update a field in table via an AfterUpdate event procedure.
Basically two tables:
tblPurchaseOrderItems
f: POrderItemsID - Autonumber
f: ComponentID - Look up to another table
f: QtyOrdered - Number
f: QtyOS - Number (populated by frmPOrderItems.QtyOrdered_AfterUpdate)
Basically copies same value as qty ordered as being qty outstanding.
tblGoodsInItems
f: GoodsInItemsID - Autonumber
f: POrderItemsID - Table Look Up (above) Displays Component and qty ordered
etc.
f: QtyOS - populated by POrderItems.column(4) by AfterUpdate
f: QuantityRecieved - Number
Ok what i then have is a frmGoodsIn with a subform frmGoodInItems (linked to
relavent table)
What i eventually want to do is in the frmGoodsInItems.POrderItemsID combo
is only display the relevent fields (Components ordered) where
tblPurchaseOrderItems.QtyOS is not = 0. So if i recieve my first lot of
goods in all the items purchase should have QtyOS = QtyOrder then as i select
an item and enter QuantityRecieved If that = QtyOrdered then i need to set
the QtyOS to 0 but if not then set QtyOS to however many it needs to be.
However I have no idea how to UPDATE a field in a table using VBA, I have
tried using the following code but it stops at the CurrentDb line i've tried
with and without () Any help greatly appreciated.
Private Sub QuantityRecieved_AfterUpdate()
Dim intQuantity As Integer
Dim strSQL As String
intQuantity = Me!QtyOS - Me!QuantityRecieved
If intQuantity = 0 Then
strSQL = "UPDATE tblPurchaseOrderItems SET QtyOS = 0 " & _
"WHERE POrderItemsID = Me.POrderItemsID"
CurrentDb().Execute strSQL, dbFailOnError
Else
strSQL = "UPDATE tblPurchaseOrderItems " & _
"SET QtyOS = intQuantity " & _
"WHERE POrderItemsID = Me.POrderItemsID"
CurrentDb.Execute strSQL, dbFailOnError
End If
End Sub
Cheers
Terry
I'm trying to update a field in table via an AfterUpdate event procedure.
Basically two tables:
tblPurchaseOrderItems
f: POrderItemsID - Autonumber
f: ComponentID - Look up to another table
f: QtyOrdered - Number
f: QtyOS - Number (populated by frmPOrderItems.QtyOrdered_AfterUpdate)
Basically copies same value as qty ordered as being qty outstanding.
tblGoodsInItems
f: GoodsInItemsID - Autonumber
f: POrderItemsID - Table Look Up (above) Displays Component and qty ordered
etc.
f: QtyOS - populated by POrderItems.column(4) by AfterUpdate
f: QuantityRecieved - Number
Ok what i then have is a frmGoodsIn with a subform frmGoodInItems (linked to
relavent table)
What i eventually want to do is in the frmGoodsInItems.POrderItemsID combo
is only display the relevent fields (Components ordered) where
tblPurchaseOrderItems.QtyOS is not = 0. So if i recieve my first lot of
goods in all the items purchase should have QtyOS = QtyOrder then as i select
an item and enter QuantityRecieved If that = QtyOrdered then i need to set
the QtyOS to 0 but if not then set QtyOS to however many it needs to be.
However I have no idea how to UPDATE a field in a table using VBA, I have
tried using the following code but it stops at the CurrentDb line i've tried
with and without () Any help greatly appreciated.
Private Sub QuantityRecieved_AfterUpdate()
Dim intQuantity As Integer
Dim strSQL As String
intQuantity = Me!QtyOS - Me!QuantityRecieved
If intQuantity = 0 Then
strSQL = "UPDATE tblPurchaseOrderItems SET QtyOS = 0 " & _
"WHERE POrderItemsID = Me.POrderItemsID"
CurrentDb().Execute strSQL, dbFailOnError
Else
strSQL = "UPDATE tblPurchaseOrderItems " & _
"SET QtyOS = intQuantity " & _
"WHERE POrderItemsID = Me.POrderItemsID"
CurrentDb.Execute strSQL, dbFailOnError
End If
End Sub
Cheers
Terry