Results 1 to 3 of 3
  1. #1
    tmartin is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    37

    How to save or Undo a Form when using acAdd in DoCmd.OpenForm.....

    DoCmd.OpenForm "NewTransaction", acNormal, "Query4TransactionForm", "[EmployeeID]=[TempVars]![loginID]", acAdd, acNormal



    When I implement the DoCmd as shown above, an blank form is presented that can be populated. If I edit the content and then close the form,
    the database is updated. Is there anyway to cancel what you have edited? Is there anyway to manually save the form?

    My Workaround -
    I created an unbounded form and then called a VBA sub to read the content of the form and create a new record in the database. I am just wondering
    about the procedure above if there is a way to control updating the database

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    In general, an unbound form gives you the most control. There are some thoughts here:

    http://www.baldyweb.com/BoundUnbound.htm

    You can probably abort the record saving on a bound form with the Undo method, probably called from the form's before update event.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by tmartin View Post

    ...Is there anyway to cancel what you have edited? Is there anyway to manually save the form?
    To Cancel a New Record or Edit of Record

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Not (Me.NewRecord) Then
      If MsgBox("Would You Like To Save The Changes To This Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save Changes to Record ???") = vbNo Then
       Me.Undo
      End If
    Else
      If MsgBox("Would You Like To Save This New Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save This New Record ???") = vbNo Then
       Me.Undo
      End If
    End If
    End Sub


    To Save a Record

    Code:
    Private Sub cmdSaveRecord_Click()
     DoCmd.RunCommand acCmdSaveRecord
    End Sub

    Linq ;0)>

Please reply to this thread with any new information or opinions.

Similar Threads

  1. DoCmd.OpenForm; 3rd Argument = FilterName
    By Access_Novice in forum Programming
    Replies: 1
    Last Post: 02-02-2014, 11:05 PM
  2. Slow Opening Form using DoCmd.OpenForm
    By timfoster in forum Forms
    Replies: 12
    Last Post: 02-01-2014, 04:00 AM
  3. docmd.gotocontrol after undo
    By JeroenMioch in forum Forms
    Replies: 7
    Last Post: 08-19-2013, 12:47 PM
  4. What actually happens at docmd.openform
    By Beorn in forum Programming
    Replies: 4
    Last Post: 01-05-2011, 02:19 PM
  5. DoCmd.OpenForm Modification
    By alsoto in forum Forms
    Replies: 6
    Last Post: 05-01-2009, 07:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums