Error 7878 (data has been changed) (1 Viewer)

Mikahell

New member
Local time
Yesterday, 19:29
Joined
Sep 7, 2008
Messages
3
Hi all, I'm having this problem with error 7878, which from other posts I have seen would be an error occuring when 2 users edit the same data at the same time. However, I'm currently developping so I am the only one in the database, always. I'm trying to send the value of the primary key in some form to a parent form which will receive it in a foreign key field. On my first described form, when I click a button, it closes the form and send in a global variant the value of the textbox representing the primary key, so the other form can receive it.

It works great, unless I edit data in the first form and exit the form without firstly clicking the record selector control to save the modified data (generates error 7878). I got desperate and tried various things to force access to save the current record before closing the form, but the error persists.

I have tried including in my close button click's event procedure combinations of all the following, but the error still persists:( :
DoCmd.Save
RunCommand acCmdSaveRecord
Me.Requery
Me.Refresh
DbEngine.Idle dbRefreshCache
Sleep(1000)

From what I understand, the saving of the record really happens (one would hope, after calling so many kind of save functions) but it "happens" only after the button's event is finished... But since the form closes in the button's click, the data is "being saved but not really completed". If I can be clearer, I think that the form's record is only saved once all user-functions stack are done and that the focus is sent back to the form, or so...

I suppose it works this way, and I wanted to know if there's a kind of method to pause the execution of the current event and force the refreshing of the form (like a multi-threaded app would wait until one process is completely finished before continuing another task), so that the form would really get to "Me.Dirty = False" state before the form closes, avoiding error 7878.

I've heard multithreading in access is impossible, but I don't believe it, since I have seen a user progressbar control (wish I had the code -_-) that does a loop of actions and increments the progressbar's filling to the right and we can see it filling slowly to the end. I believe that means that there IS a way to update the form even if code is still running in background.

Hope all is clear, thanks in advance
 
Local time
Yesterday, 21:29
Joined
Mar 4, 2008
Messages
3,856
It is not clear, but that won't stop me from answering what I think your question is.

In order to force events to happen in code before the next line of code executes, use "DoEvents()". It's very simple but you can look it up in VB help, if you like.

Access/VB have multi-threading problems (thankfully not the same kind of problems you get in C/C++). DoEvents is one of the tools used to fix them (or make them worse). If you ever have a long-running program loop that is constantly busy, you should put a DoEvents() in the loop so the loop can be broken and other programs can continue to run normally.

Your problem makes no sense to me. I've never had anything like that in thousands of forms.
 

Mikahell

New member
Local time
Yesterday, 19:29
Joined
Sep 7, 2008
Messages
3
thanks I will look forward to this, sorry if it's unclear.
This problem doesn't make sense to me either :)
 

boblarson

Smeghead
Local time
Yesterday, 19:29
Joined
Jan 12, 2001
Messages
32,059
By the way

This code:

DoCmd.Save

has NOTHING to do with RECORDS. It deals with DESIGN changes. If you want to save a record explicitly you would use either:

If Me.Dirty Then Me.Dirty = False

or

DoCmd.RunCommand acCmdSaveRecord
 

Mikahell

New member
Local time
Yesterday, 19:29
Joined
Sep 7, 2008
Messages
3
For DoCmd.Save, I felt like it had to do with design changes but I wasn't too sure so I deceided to try it in my desperation. Ahah, still thanks to the both of you, using DoEvents and playing with Dirty property I managed to make everything works!
 
Local time
Yesterday, 21:29
Joined
Mar 4, 2008
Messages
3,856
Glad you got it sorted out. Sometimes all it takes is kicking it around a little with other people.
 

Users who are viewing this thread

Top Bottom