Solved

Record was already edited error.

Posted on 2008-10-10
6
184 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
  • 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

914 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

14 Experts available now in Live!

Get 1:1 Help Now