Solved

Record was already edited error.

Posted on 2008-10-10
6
190 Views
Last Modified: 2013-11-28
I have access frontend and SQL Sever backend
I have a form with tblDaily as part of the record source.
I add data to a field on frmMain, then click a button to go to a 2nd form.
In the button's code, I save frmMain (docmd.Save) before I open frm2nd.
I add data to frm2nd which also has tblDaily as part of the record source.
When I close frm2nd I requery and Save again using DoCmd.Save acForm, "frmMain"
and I'm back at frmMain.
When I type data into the frmMain I get the message...
    The data has been changed.
    Another user edited this record...
    Re-edit the record.
Why?  How many more saves do I need.
Does Docmd.save not work with SQL?

0
Comment
Question by:BobRosas
[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
  • 2
6 Comments
 
LVL 84
ID: 22693236
No, DoCmd.Save won't work with SQL Server because DoCmd.Save has nothing to do with data. DoCmd.Save doesn't save your DATA, it saves any changes you've made to your FORM, and SQL Server has nothing to do with Form, Reports etc. Use this instead:

If Me.Dirty Then Me.Dirty = False

Note this will only work on the current object. If you need to save data on another form:

If Forms("YourFormName").Dirty Then Forms("YourFormName").Dirty = False



0
 

Author Comment

by:BobRosas
ID: 22703233
Thank you so much for your response.
Would you explain more how this works?  
I think by setting the form to Me.Dirty I'm tricking it into thinking there are no previous changes so that I don't get the message.  If that's true, I'm not sure where to put the code.  I entered the code under 'On Activate" of the Main form so that when I go back to it from the second form I can enter more data but I'm still getting the same "data has been changed etc" message.
I really appreciate your help.
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 125 total points
ID: 22703441
You're not setting the Form to Dirty, you're querying the form's Dirty property and, if True, then you're setting that Property to False, which forces Access to save your data.

Where you put this depends on where you need to force a save. Access typically saves when the record is "moved" (i.e you navigate to a different record, add a new record, etc) or when you explicitly call for a Save operation (via Code, menu selection, etc).

I'd do this BEFORE I moved off the first form ... IOW, in the Click event that opens your 2nd form, just before you open that form.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:BobRosas
ID: 22704012
Your explanation makes sense but I can't get it to work.
When I click on the button in form 1 to open form 2(frmDFT) I put in your code.  See attached.
I also added the code in the 2nd form on close for both forms.
I'm still getting the message on form one.

CODE WITHIN FIRST FORM
Private Sub cmdOpnDFT_Click()
    If IsNull(cboQCReportNo) Then
        MsgBox "You must enter a ReportNo and VersionNo to open this form."
        Exit Sub
    End If
    If Me.Dirty Then Me.Dirty = False
    DoCmd.OpenForm "frmDFT", acNormal
End Sub
 
CODE WITHIN 2ND FORM
Private Sub Form_Close()
    If Me.Dirty Then Me.Dirty = False
    If Forms("frmDaily").Dirty Then Forms("frmDaily").Dirty = False
End Sub

Open in new window

0
 

Author Comment

by:BobRosas
ID: 22705559
There is a subform within the first main form that is auto filled.  Maybe that is the problem.  So I tried adding code to account for that but I've tried all the examples below and none of them will work.
Any thoughts?
Thanks again!

    If Forms("fsubDaily").Dirty Then Forms("fsubDaily").Dirty = False
    If Me.fsubDaily.Dirty Then Me.fsubDaily.Dirty = False
    If Forms!fsubDaily!Dirty Then Forms!fsubDaily.Dirty = False
    If Forms("Me!fsubDaily").Dirty Then Forms("Me!fsubDaily").Dirty = False
0
 

Author Closing Comment

by:BobRosas
ID: 31505119
Thanks for your help.  I'll repost another question.
0

Featured Post

Independent Software Vendors: 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.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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…

752 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