Hi all,
Could really use some help with my VBA code, I'm trying to add all the records of one table (tasks) to another (employee_tasks) using a while loop. The main field that needs to be added it the task ID but at the moment it keeps crashing when I try and run it which I'm pretty sure is because its creating too many new records. below is the code and any help will be greatly appreciated. Thanks in advance.
Dim dbs As Database
Dim rsTasks As DAO.Recordset
Dim rsemployee_tasks As DAO.Recordset
Set dbs = CurrentDb()
Set rsemployee_tasks = dbs.OpenRecordset("employee_tasks")
Set rsTasks = dbs.OpenRecordset("Tasks")
rsTasks.MoveFirst
Do Until rsTasks.EOF
If Not IsNull(rsTasks![task_ID]) = False Then
rsemployee_tasks.AddNew
rsemployee_tasks.Update
End If
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
Could really use some help with my VBA code, I'm trying to add all the records of one table (tasks) to another (employee_tasks) using a while loop. The main field that needs to be added it the task ID but at the moment it keeps crashing when I try and run it which I'm pretty sure is because its creating too many new records. below is the code and any help will be greatly appreciated. Thanks in advance.
Dim dbs As Database
Dim rsTasks As DAO.Recordset
Dim rsemployee_tasks As DAO.Recordset
Set dbs = CurrentDb()
Set rsemployee_tasks = dbs.OpenRecordset("employee_tasks")
Set rsTasks = dbs.OpenRecordset("Tasks")
rsTasks.MoveFirst
Do Until rsTasks.EOF
If Not IsNull(rsTasks![task_ID]) = False Then
rsemployee_tasks.AddNew
rsemployee_tasks.Update
End If
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub