herbertioz
Registered User.
- Local time
- Today, 09:44
- Joined
- Nov 6, 2009
- Messages
- 66
I have a database linked to another and the task is to sum each record from scale1, delete current record (after calc sum) and put it into another table in another database.
How can I ensure that each record sum, record for record and delete it afterwords?
How can I ensure that each record sum, record for record and delete it afterwords?
Code:
Option Compare Database
Private Sub Form_Timer()
Dim db As Database
Dim Sum As Integer
Sum = 0
Dim rs As DAO.Recordset
Set db = CurrentDb()
LSQL = "select weight from scale1"
Set rs = db.OpenRecordset(LSQL)
Do While Not rs.EOF
Sum = Sum + rs("weight")
sSql1 = "UPDATE loadings SET loaded_Weight = " & Sum & " WHERE ID = " & Me.ID.Value & ";"
CurrentDb.Execute (sSql1)
rs.MoveNext
Loop
' Delete weight
'sSql = "Delete * from scale1 where weight=" & rs("weight")
'CurrentDb.Execute (sSql)
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub