rainsworth
Programmer
I have a form called startChklst. It has 2 sub forms: Current_Tasks and Finished_tasks. The subforms have tables named Current_Tasks and Finished_tasks associated with them. The subforms are continuous forms. Basically they display tasks that are unfinished tasks and finished tasks. When one clicks on a checkbox control I execute a module that does all of the record moving and redisplaying of the form. When reaching the line Forms!startChklst.Refresh. Ms Access closes with out preamble. When toggling a break point at this line a msgBox is diplayed indication Run-Time error 3167 'Record is deleted".
Here is the code:
Option Compare Database
Public rstCurrent As DAO.Recordset
Public rstFinished As DAO.Recordset
Public dbs As Database
------------------------------------------------------------
Sub MoveRecords()
Set dbs = CurrentDb
Set rstCurrent = dbs.OpenRecordset("Current_tasks"
Set rstFinished = dbs.OpenRecordset("Finished_Tasks"
' Move Record from Current_tasks table to Finished_tasks table.
rstFinished.AddNew
rstFinished!Task_no = Forms!startChklst.Form!Current_tasks!Task_no.Value
rstFinished!Time = Forms!startChklst.Form!Current_tasks!Time.Value
rstFinished!Date = Forms!startChklst.Form!Current_tasks!Date.Value
rstFinished!Day = Forms!startChklst.Form!Current_tasks!Day.Value
rstFinished!Task = Forms!startChklst.Form!Current_tasks!Task.Value
rstFinished!Location = Forms!startChklst.Form!Current_tasks!Location.Value
rstFinished!Time_stamp = Time()
rstFinished!User_Id = UID
rstFinished.Update
' Move the record pionter to the Finished record
' Delete Finished Record from Current_tasks and refresh the form.
Move_record_pointer_to_Currently_checked_record
rstCurrent.Delete
rstCurrent.MoveNext
'Forms!startChklst.Requery
Forms!startChklst.Refresh 'MS Access closes here
End Sub
------------------------------------------------------------
Sub Move_record_pointer_to_Currently_checked_record()
rstCurrent.MoveFirst
Do While rstCurrent.Fields![Completed].Value = False And rstCurrent.Fields![Task_no] <> Forms!startChklst.Form!Current_tasks!Task_no.Value
' Are we on the correct record ?
rstCurrent.MoveNext
Loop
End Sub
Here is the code:
Option Compare Database
Public rstCurrent As DAO.Recordset
Public rstFinished As DAO.Recordset
Public dbs As Database
------------------------------------------------------------
Sub MoveRecords()
Set dbs = CurrentDb
Set rstCurrent = dbs.OpenRecordset("Current_tasks"
Set rstFinished = dbs.OpenRecordset("Finished_Tasks"
' Move Record from Current_tasks table to Finished_tasks table.
rstFinished.AddNew
rstFinished!Task_no = Forms!startChklst.Form!Current_tasks!Task_no.Value
rstFinished!Time = Forms!startChklst.Form!Current_tasks!Time.Value
rstFinished!Date = Forms!startChklst.Form!Current_tasks!Date.Value
rstFinished!Day = Forms!startChklst.Form!Current_tasks!Day.Value
rstFinished!Task = Forms!startChklst.Form!Current_tasks!Task.Value
rstFinished!Location = Forms!startChklst.Form!Current_tasks!Location.Value
rstFinished!Time_stamp = Time()
rstFinished!User_Id = UID
rstFinished.Update
' Move the record pionter to the Finished record
' Delete Finished Record from Current_tasks and refresh the form.
Move_record_pointer_to_Currently_checked_record
rstCurrent.Delete
rstCurrent.MoveNext
'Forms!startChklst.Requery
Forms!startChklst.Refresh 'MS Access closes here
End Sub
------------------------------------------------------------
Sub Move_record_pointer_to_Currently_checked_record()
rstCurrent.MoveFirst
Do While rstCurrent.Fields![Completed].Value = False And rstCurrent.Fields![Task_no] <> Forms!startChklst.Form!Current_tasks!Task_no.Value
' Are we on the correct record ?
rstCurrent.MoveNext
Loop
End Sub