A family of Microsoft relational database management systems designed for ease of use.
I am trying to write the below code, to confirm that the record is added.
Then only to go for next record.
But confused, what function is the correct in my situation
Sleep OR Wait OR DoEvent
Please check by below code and advise, if I ok going or need to modify my code to suit better
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
Dim sqlstr As String
Dim CountMyReco As Integer
Dim HoldCountReco As Integer
Dim LCounter As Integer
CountMyReco = DCount("RecoNo", TableMasterDV
HoldCountReco = DCount("RecoNo", TableMasterDV)
sqlstr = "SELECT TableMasterLocal.* FROM TableMasterLocal LEFT JOIN TableMasterDV ON TableMasterLocal.SerialNo = TableMasterDV.SerialNo WHERE TableMasterDV.SerialNo Is Null;"
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("TableMasterDV")
Set rs2 = db.OpenRecordset(sqlstr)
rs2.MoveFirst
Do Until rs2.EOF
rs1.AddNew
rs1!RecoNo = Nz(DMax("[RecoNo]", "[TableMasterDV]"), 0) + 1
rs1!Model = rs2!Model
rs1!SerialNo = rs2!SerialNo
rs1!SMR = rs2!SMR
rs1!WorkingHrs = rs2!WorkingHrs
rs1!ActWorkHrs = rs2!ActWorkHrs
rs1!TotalFuel = rs2!TotalFuel
rs1!FuelPerHr = rs2!FuelPerHr
rs1!Cautions = rs2!Cautions
rs1.Update
For LCounter = 1 To 8
If CountMyReco = HoldCountReco Then
Exit For
Else
Sleep (10000) 'confused what will be correct - Sleep OR Wait OR DoEvent
End If
Next LCounter
rs2.MoveNext
Loop
rs1.Close
rs2.Close
Set rs1 = Nothing
Set rs2 = Nothing
Set db = Nothing