Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

    To save or not to save.

    I'm using Me.Undo on a button on the form that users can click to cancel what they are doing and not save.

    recently we had minor data loss when closing a form. (I've never had any save procedures in place and its never been a problem until this once.).

    My question is. If I use this code on a close event of a form:

    Code:
    If me.dirty then
        me.dirty = false

    But I close the form after running me.undo, will there be any over lap? I want to know if its possible for it to save the record "by mistake" similar to what happened when it didn't save data.

    I feel like I've worded this terribly but hopefully someone can have some input here.

    Thanks.

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,706
    Bound or unbound form?

  3. #3
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Its bound. But the me. Undo did work in earlier testing. I'm just concerned the save event on the form close could trigger before the me.undo.

    Im guessing not. But this is the place to ask.

  4. #4
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    You could tell them to hit the Esc key to undo If they hit the Undo button it should just remove what was in-process on the form fields before it was saved(again same as using Esc key) I would think.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I avoid Undo. Perhaps you can explain why and how you are using Undo. There may be a more dependable way.

  6. #6
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    I have a form open that users can enter a date for an event. The location is selected on the previous form. The user then clicks create event and the new form pops up and all they need to enter is the date.

    These events are stored in their own table and I want to avoid blank or incorrect events on the database. That's why I was giving the user the option to cancel if they clicked the wrong one for example.

    Thanks
    Last edited by Homegrownandy; 09-07-2016 at 01:50 AM. Reason: too early to form proper sentences

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    If you close a form, the Values of the controls will be committed to the table. IIRC, other users and or other queries will not see the new record until after it is committed to the table. In other words, closing a form or navigating to another record within a form will commit data to the table.

    The Undo method will not have any affect on data that is saved/committed to the table.

    Maybe the easiest is to use pop-up modal for your date entry thing. Have a Close button that does not do anything special other than pass a variable back to the previous form. A cancel button on the previous form can run a query to delete any records the form with the date thing may have created, as well as deleting any records the current form created.

    You can check the form's properties to see if the record has been committed to the table yet.
    Code:
    If Not Me.NewRecord Then
        'Delete from table
        DoCmd.RunCommand acCmdDeleteRecord
    End If

  8. #8
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Thanks, I'm restructuring my whole database ATM, moving everything to a new one where I'm cutting out everything I don't need. Over the past year things have changed a lot and there's a lot of "junk" on the system. I'm also improving the design and functionality. So things like this where instead of just the answer I get a better solution is really appreciated.

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

Similar Threads

  1. Replies: 2
    Last Post: 07-15-2015, 08:35 PM
  2. Replies: 5
    Last Post: 02-03-2014, 03:06 AM
  3. Replies: 15
    Last Post: 01-28-2014, 12:20 PM
  4. Replies: 3
    Last Post: 10-08-2012, 08:40 AM
  5. Replies: 9
    Last Post: 01-20-2011, 02:22 PM

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