Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Save Record overwrite message keeps coming up

Posted on 2012-04-03
11
Medium Priority
?
370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 48

Expert Comment

by:Dale Fye
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
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!

 
LVL 48

Expert Comment

by:Dale Fye
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 48

Accepted Solution

by:
Dale Fye earned 2000 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 48

Expert Comment

by:Dale Fye
ID: 37829674
Great,  glad the explanation helped.
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

688 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