iainmacleod
asked on
Use of variant in Do
I have the following code that seems to work sometimes but not all of the time. If I replace the variant "Cstock" with a number then the number stores down in the table. But the variant does not. Please help
Dim Cdb As DAO.Database, sd As DAO.Recordset, ps As DAO.Recordset, strMsg As String, iResponse As Integer, cstock As Variant
Set Cdb = CurrentDb
Set sd = Cdb.OpenRecordset("stockde tails", dbOpenDynaset)
Set ps = Cdb.OpenRecordset("purchas edstock", dbOpenDynaset)
sd.MoveFirst
Do While Not sd.EOF
If sd!sid = Me.stockid Then
sd.Edit
cstock = (Me.quantity + sd!stocktotal)
sd!stocktotal = cstock
sd.Update
Forms!stockdetailalterview .stocktota l = sd!stocktotal
Forms!stockdetailalterview .available stock = sd!stocktotal - sd!stockringfenced
Forms!stockdetailalterview .Refresh
'DoCmd.Close
Exit Do
Else
sd.MoveNext
End If
Loop
Dim Cdb As DAO.Database, sd As DAO.Recordset, ps As DAO.Recordset, strMsg As String, iResponse As Integer, cstock As Variant
Set Cdb = CurrentDb
Set sd = Cdb.OpenRecordset("stockde
Set ps = Cdb.OpenRecordset("purchas
sd.MoveFirst
Do While Not sd.EOF
If sd!sid = Me.stockid Then
sd.Edit
cstock = (Me.quantity + sd!stocktotal)
sd!stocktotal = cstock
sd.Update
Forms!stockdetailalterview
Forms!stockdetailalterview
Forms!stockdetailalterview
'DoCmd.Close
Exit Do
Else
sd.MoveNext
End If
Loop
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER