Solved

Save Record overwrite message keeps coming up

Posted on 2012-04-03
11
366 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 (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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 48

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 48

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 48

Expert Comment

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

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

734 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