Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Closes with "Record is deleted" when refreshing form

Status
Not open for further replies.

rainsworth

Programmer
Feb 12, 2002
6
GB
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
 
You don't need to Refresh after Requery. Just delete that line, it won't do any harm...

Closing Access without preamble may mean that your code is corrupt or wrong somewhere. Compile everything and see if it comes with errors.

Good luck

[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top