N
NigelW_SWUK
I wish to update the units in stock when orders are added. Ken kindly gave
me the following script but I get the error Variable to be declared before
use. He said that I had to ...First make sure that you have a reference to
the Microsoft ActiveX Data
Objects Library (Tools | Refrences on the VBA menu bar).
This I don't understand - will this cause my run error?
Put the following code in the order details subform's AfterInsert event
procedure
Dim cmd As ADODB.Command
Dim strSQL As String
Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdText
strSQL = "UPDATE Products " & _
"SET UnitsInStock = UnitsInStock - " & _
Me.Quantity & " WHERE ProductID = " & _
Me.ProductID
cmd.CommandText = strSQL
cmd.Execute
me the following script but I get the error Variable to be declared before
use. He said that I had to ...First make sure that you have a reference to
the Microsoft ActiveX Data
Objects Library (Tools | Refrences on the VBA menu bar).
This I don't understand - will this cause my run error?
Put the following code in the order details subform's AfterInsert event
procedure
Dim cmd As ADODB.Command
Dim strSQL As String
Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdText
strSQL = "UPDATE Products " & _
"SET UnitsInStock = UnitsInStock - " & _
Me.Quantity & " WHERE ProductID = " & _
Me.ProductID
cmd.CommandText = strSQL
cmd.Execute