Hi all,
I have managed to sort out the data to be used in the final table. However, I am having trouble transferring the data from each of their own tables into the final table.
Each time I run my code I receive "run-time error 3021: No current record."
It seems that only my timestamp is being added properly, but the error pops up and highlights the first "rstInsert.Edit" of my code. I'm suspecting that my function is running too fast, such that it did not have time to read that the table has already been populated by the timestamp in the AddNew code
How do I solve this?
I have managed to sort out the data to be used in the final table. However, I am having trouble transferring the data from each of their own tables into the final table.
Each time I run my code I receive "run-time error 3021: No current record."
It seems that only my timestamp is being added properly, but the error pops up and highlights the first "rstInsert.Edit" of my code. I'm suspecting that my function is running too fast, such that it did not have time to read that the table has already been populated by the timestamp in the AddNew code
How do I solve this?
Code:
Private Sub Command9_Click()
Dim dbs As DAO.Database
Dim rstTimestamp As DAO.Recordset
Dim rstAcknowledgement As DAO.Recordset
Dim rstAgent As DAO.Recordset
Dim rstDetails As DAO.Recordset
Dim rstInsert As DAO.Recordset
Set dbs = CurrentDb
Set rstTimestamp = dbs.OpenRecordset("GMT+8", dbOpenDynaset)
Set rstAcknowledgement = dbs.OpenRecordset("Acknowledgement", dbOpenDynaset)
Set rstAgent = dbs.OpenRecordset("AgentName", dbOpenDynaset)
Set rstDetails = dbs.OpenRecordset("Table2", dbOpenDynaset)
Set rstInsert = dbs.OpenRecordset("Final", dbOpenDynaset)
If Not rstTimestamp.EOF Then
Do
rstInsert.AddNew
rstInsert![Timestamp] = rstTimestamp![Timestamp (GMT+8)]
rstInsert.Update
rstTimestamp.MoveNext
Loop Until rstTimestamp.EOF
End If
RefreshDatabaseWindow
If Not rstAcknowledgement.EOF Then
Do
rstInsert.Edit
rstInsert![SNOCAcknowledged] = rstAcknowledgement![Field2]
rstInsert.Update
rstAcknowledgement.MoveNext
Loop Until rstAcknowledgement.EOF
End If
RefreshDatabaseWindow
If Not rstAgent.EOF Then
Do
rstInsert.Edit
rstInsert![AgentName] = rstAgent![Field2]
rstInsert.Update
rstAgent.MoveNext
Loop Until rstAgent.EOF
End If
RefreshDatabaseWindow
If Not rstDetails.EOF Then
Do
rstInsert.Edit
rstInsert![Details] = rstDetails![Field5]
rstInsert.Update
rstDetails.MoveNext
Loop Until rstDetails.EOF
End If
End Sub
Last edited: