Hi, im practising with ADO and i have the following problem
I need to subtrack from order details quantity with productid.
but how can i use subtrack? it gives me debug error
here is the code
Private Sub button_Click()
Dim lookupcheck As String
Dim apo As Integer
Dim cnn1 As ADODB.Connection
Dim myrecordset As New ADODB.Recordset
Set cnn1 = CurrentProject.Connection
myrecordset.ActiveConnection = cnn1
myrecordset.Open " SELECT * " & _
" FROM [products] INNER JOIN TransactionLine ON " & _
"[products].PrId = TransactionLine.Prid ", cnn1, adOpenStatic, adLockOptimistic
lookupcheck = DLookup("[CurrentStock]", "products", "products.prid=TransactionLine.PrId")
If DLookup("[Apothema]", "products", "products.prid=TransactionLine.PrId") < Forms![transactionline].Quantity Then
MsgBox "Error : " & lookupcheck & "", vbCritical, "Error"
Else
Do Until myrecordset.EOF
myrecordset.Fields("CurrentStock") = Forms![transactionline].Quantity - myrecordset.Fields("CurrentStock")
myrecordset.UpdateBatch '//(all the records like productid=1,2,3,or 4 with different quantity)
myrecordset.MoveNext
Loop
MsgBox "Updates Success", , "Update"
End If
myrecordset.Close
Set myrecordset = Nothing
End Sub