runtime error
hey guys im having this error on executing this code;
must use dbSeeChanges option with Recordset
Private Sub type_AfterUpdate()
Dim db As Database, tb As Recordset, rs As Recordset, ns As Recordset
Set db = CurrentDb
Set tb = db.OpenRecordset("Select * from Materialtable1 where ID =" & Me.Type.Column(1), dbSeeChanges)
Set rs = db.OpenRecordset("Select * from InventoryTransactions", dbSeeChangess)
Set ns = db.OpenRecordset("Select * from InventoryTransactions Where ProductID=" & Me.ProductID, dbSeeChanges)
Do Until ns.EOF = True
With ns
ns.Delete
ns.MoveNext
End With
Loop
ns.Close
Do Until tb.EOF = True
With tb
rs.AddNew
rs!ProductID = ProductID
rs!material = tb!Material1
rs!Rate = tb!Rate1
rs!Unit = tb!Unit1
rs!MaterialID = tb!MaterialID
rs.Update
End With
tb.MoveNext
Loop
rs.Close
tb.Close
db.Close
Me.Refresh
Me.Requery
End Sub
wats the solution
hey guys im having this error on executing this code;
must use dbSeeChanges option with Recordset
Private Sub type_AfterUpdate()
Dim db As Database, tb As Recordset, rs As Recordset, ns As Recordset
Set db = CurrentDb
Set tb = db.OpenRecordset("Select * from Materialtable1 where ID =" & Me.Type.Column(1), dbSeeChanges)
Set rs = db.OpenRecordset("Select * from InventoryTransactions", dbSeeChangess)
Set ns = db.OpenRecordset("Select * from InventoryTransactions Where ProductID=" & Me.ProductID, dbSeeChanges)
Do Until ns.EOF = True
With ns
ns.Delete
ns.MoveNext
End With
Loop
ns.Close
Do Until tb.EOF = True
With tb
rs.AddNew
rs!ProductID = ProductID
rs!material = tb!Material1
rs!Rate = tb!Rate1
rs!Unit = tb!Unit1
rs!MaterialID = tb!MaterialID
rs.Update
End With
tb.MoveNext
Loop
rs.Close
tb.Close
db.Close
Me.Refresh
Me.Requery
End Sub
wats the solution
Last edited: