Solved

Save Record overwrite message keeps coming up

Posted on 2012-04-03
11
365 Views
Last Modified: 2012-08-14
I have an employee form on which is a button for the termination form.  When the user clicks on the termination button, the employee form closes.  The user enters the termination data and when they hit the "terminate/close" button, the process records the termination data, closes the termination form and then should open the employee form.  BUT every time the termination form closes and the employee form opens, I get that darn save record/drop changes/ message as though two people are trying to cvhange the same record.  To avoid this, I have the employee form close when the terminate form opens and then re-open when the terminate form closes so I really don't know why this keeps happening.  However, could it be that since I have to open the employee form before the terminate form closes, it is conflicting?

Sandra
0
Comment
Question by:ssmith94015
  • 4
  • 4
  • 3
11 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 37802158
<<when they hit the "terminate/close" button, the process records the termination data, closes the termination form and then should open the employee form>>

What order are you closing/opening the forms when this button is clicked, and what code executes in the open event of the employee form?


If you are opening the employee form before closing the other form, try adding the following immediately before opening the employee form:


Me.Refresh
Docmd.OpenForm "frmEmployees"
Docmd.close acform, me.name
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 37802169
This is likely because you have edited the record on the Employee form, then opened the Termination form without first saving any changes.

In the button that opens the Termination form, add:

Me.Dirty = False

prior to the line that opens the Termination form.
0
 

Author Comment

by:ssmith94015
ID: 37802348
Neither worked.  When the termination form has updated the record, the frmEmployees is opened and then the frmEmpTerminate is closed.  

on the frmEmployees to open the terminate form

    DoCmd.OpenForm "frmEmpTerminate", acNormal, , "EmpFRBEmployeeNumber = " & Me.EmpFRBEmployeeNumber & ""
    DoCmd.Close acForm, Me.Name

On the frmEmpTerminate when the record has been updated and ready to go back to frmEmployees

    DoCmd.OpenForm "frmEmployees"
    DoCmd.Close acForm, Me.Name

When the frmEmpTerminate is opened from the frmEmployees, I have the frmEmployees form closed.  I thought that would then free up the record for updating and the update would not impact frmEmployee when it was opened, teh change was recorded on the frmEmpTerminate.  

Sandra
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 37802386
"When the frmEmpTerminate is opened from the frmEmployees, I have the frmEmployees form closed"

No, you don't, you are not closing that form until after you open frmEmpTerminate.  Try:

    me.Dirty = False
    DoCmd.OpenForm "frmEmpTerminate", acNormal, , "EmpFRBEmployeeNumber = " & Me.EmpFRBEmployeeNumber & ""
    DoCmd.Close acForm, Me.Name

Then,

    me.Dirty = False
    DoCmd.OpenForm "frmEmployees"
    DoCmd.Close acForm, Me.Name
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37802392
Have you tried refreshing the forms going both ways (its not clear to me where the error is occurring):


Me.refresh
DoEvents '<-- add this
    DoCmd.OpenForm "frmEmpTerminate", acNormal, , "EmpFRBEmployeeNumber = " & Me.EmpFRBEmployeeNumber & ""
    DoCmd.Close acForm, Me.Name




Me.refresh
DoEvents
DoCmd.OpenForm "frmEmployees"
    DoCmd.Close acForm, Me.Name
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37802400
Also, are we dealing with an Access or SQL Backend?  SQL Backends can cause this message for seemingly unrelated reasons (for example, allowing nulls in boolean fields in a SQL back end can cause this error).
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 37802459
@ssmith

Let me describe to you what I think is happening.  If I'm off, let me know

1.  You open frmEmployees and move to the record.

2.  You change some item of information on frmEmployees, then click on a command button that opens frmEmpTerminate, without first saving the changes you made to frmEmployees.

3.  When you opened frmEmpTerminate, it gets filtered to the employee whose record was on frmEmployees.  Because you didn't save the changes to frmEmployee before opening frmEmpTerminate, the values of the fields used in this form will be what was on frmEmployees when you first got to the individiual you are going to terminate.

4.  Once frmEmpTerminate is open, your code closes frmEmployees, which finally writes the changes you made to that record.  But now frmEmpTerminate contains old data, which was overwritten by your closing frmEmployees.

5.  When you go to close frmEmpTerminate, you first open frmEmployees (but you are not filtering it, so you are not going back to the employees record that you are terminating.  However, when you close frmEmpTerminate, you are taking data that is "older" than the data that is currently saved in tblEmployees for that employee, which is what is causing the warning message.

So, you should be able to get away with just adding the one line, in the routine that opens frmEmpTerminate

    me.Dirty = False   '<<<< add this line
    DoCmd.OpenForm "frmEmpTerminate", acNormal, , "EmpFRBEmployeeNumber = " & Me.EmpFRBEmployeeNumber & ""
    DoCmd.Close acForm, Me.Name

HTH
Dale
0
 

Author Comment

by:ssmith94015
ID: 37807305
This is an ACCES 2003 database, no SQL backend.  Will try some of the suggestions later today, thank you all.

Sandra
0
 

Author Comment

by:ssmith94015
ID: 37820223
Not forgotten this, just pulled to an emergency project.

Sandra
0
 

Author Closing Comment

by:ssmith94015
ID: 37829639
Your sceanrio is correct, I simply did not think it through.  Actually, thank you for the full dialog as re-reading, I realized why I was getting the error and the problem.   I needed to save the first change before I did anything else as the record was "dirty", I did a little re-write to save the record when the terminate form opens and it seems to be working.

Sandra
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 37829674
Great,  glad the explanation helped.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question