R
Robert
I have gotten off track with the procedure below and
need help finding where I've gone wrong.
Here is what I am trying to do...
I have a form opened which is named Sales. There are
two controls on that form which I am using.
Item and SaleQty
I want to open a recordset of the table tblItem.
There are two controls of tblItem I am going to
use, they are
Item and InStock
Then find the record Item of tblItem which is equal
to Forms!Sales!item.
Once this record is found, then I want to update
the InStock control where
InStock = InStock - SaleQty
This is the code...
Private Sub SaleQty_AfterUpdate()
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
Set rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.Source = "tblItem"
rst.Open Options:=adCmdTable
With rst
.Find [Item]
If .EOF Then
MsgBox "No Item was found!"
Else
.Fields("InStock") = "[InStock] - Forms!Sales!
SaleQty"
.Update
End If
End With
rst.Close
Set rst = Nothing
End Sub
need help finding where I've gone wrong.
Here is what I am trying to do...
I have a form opened which is named Sales. There are
two controls on that form which I am using.
Item and SaleQty
I want to open a recordset of the table tblItem.
There are two controls of tblItem I am going to
use, they are
Item and InStock
Then find the record Item of tblItem which is equal
to Forms!Sales!item.
Once this record is found, then I want to update
the InStock control where
InStock = InStock - SaleQty
This is the code...
Private Sub SaleQty_AfterUpdate()
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
Set rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.Source = "tblItem"
rst.Open Options:=adCmdTable
With rst
.Find [Item]
If .EOF Then
MsgBox "No Item was found!"
Else
.Fields("InStock") = "[InStock] - Forms!Sales!
SaleQty"
.Update
End If
End With
rst.Close
Set rst = Nothing
End Sub