Solved

Save Record overwrite message keeps coming up

Posted on 2012-04-03
11
353 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
Comment Utility
<<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)
Comment Utility
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
Comment Utility
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)
Comment Utility
"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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 61

Expert Comment

by:mbizup
Comment Utility
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
Comment Utility
@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
Comment Utility
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
Comment Utility
Not forgotten this, just pulled to an emergency project.

Sandra
0
 

Author Closing Comment

by:ssmith94015
Comment Utility
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)
Comment Utility
Great,  glad the explanation helped.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
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…

772 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

12 Experts available now in Live!

Get 1:1 Help Now