I have 2 tables - PPMExportTBL (PPME) and PPMVisits (PPMV).
In PPME there are records for apartments with and AssetID against them.
For example record 1 to 4 is for Apartment 1 and therefore has 4 separate AssetIDs.
I need to loop through PPME and update a single record in PPMV with the various AssetIDs.
The first record updates OK. Then it all goes wrong.
This is the code I am using.
My first time posting here so I hope I have got this correct.
I would appreciate any help.
thank you
In PPME there are records for apartments with and AssetID against them.
For example record 1 to 4 is for Apartment 1 and therefore has 4 separate AssetIDs.
I need to loop through PPME and update a single record in PPMV with the various AssetIDs.
The first record updates OK. Then it all goes wrong.
This is the code I am using.
My first time posting here so I hope I have got this correct.
I would appreciate any help.
thank you
Code:
Private Sub Command0_Click()
Dim dbs As DAO.Database, stdocname As String, rpt As Report, ppmv As DAO.Recordset, fcud As DAO.Recordset, myCopies As Integer, Apnum As Variant, fcunum As Variant
Set dbs = CurrentDb
Set ppmv = dbs.OpenRecordset("ppmvisits", dbOpenDynaset)
Set ppme = dbs.OpenRecordset("ppmexportTBL", dbOpenDynaset)
ppmv.MoveFirst
Do Until ppmv.EOF
ppme.MoveFirst
Do Until ppme.EOF
If ppmv!aptid = ppme!aptid Then
ppmv.Edit
ppmv!AssetID1 = ppme!assetid
ppmv!visitdate = ppme!visitdate
ppmv.Update
ppme.MoveNext
Else
ppmv.MoveNext
End If
If ppmv!aptid = ppme!aptid Then
ppmv.Edit
ppmv!AssetID2 = ppme!assetid
ppmv.Update
ppme.MoveNext
Else
ppmv.MoveNext
End If
If ppmv!aptid = ppme!aptid Then
ppmv.Edit
ppmv!AssetID3 = ppme!assetid
ppmv.Update
ppme.MoveNext
Else
ppmv.MoveNext
End If
If ppmv!aptid = ppme!aptid Then
ppmv.Edit
ppmv!AssetID4 = ppme!assetid
ppmv.Update
ppme.MoveNext
Else
ppmv.MoveNext
End If
If ppmv!aptid = ppme!aptid Then
ppmv.Edit
ppmv!AssetID5 = ppme!assetid
ppmv.Update
ppme.MoveNext
Else
ppmv.MoveNext
End If
If ppmv!aptid = ppme!aptid Then
ppmv.Edit
ppmv!AssetID6 = ppme!assetid
ppmv.Update
ppme.MoveNext
Else
ppmv.MoveNext
End If
If ppmv!aptid = ppme!aptid Then
ppmv.Edit
ppmv!AssetID7 = ppme!assetid
ppmv.Update
ppme.MoveNext
Else
ppmv.MoveNext
End If
Loop
ppmv.MoveNext
Loop
End Sub