Solved

Save Record overwrite message keeps coming up

Posted on 2012-04-03
11
359 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
 
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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now