Results 1 to 6 of 6
  1. #1
    Astron2012 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    54

    Question Need help with adding a prompt to save changes in table

    Hi,

    I am converting a large spreadsheet of jobs into a Access 2007 database for me and one other to use. Due to the large number of columns it is impossible to fit it all comfortably in a form with continuous forms view.

    We need to be able to see all records and columns at once, like excel (I no this is probably every Access programmers worst nightmare as this is not really what access is designed for) but we need to be able to access/modify the data simultaneously so therefore excel is not a viable option.

    Due to this I have created a form with subform that shows in datasheet view. This works and looks fine apart from the autosave feature as there may be instances where users may make changes to the data without realising. I would therefore like to add code to the subform that will prompt the user to save changes.

    Normally I use the following code for usual forms which works a treat;
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim ctl As Control
    On Error GoTo Err_BeforeUpdate
    ' The Dirty property is True if the record has been changed.
    If Me.Dirty Then
    ' Prompt to confirm the save operation.
    If MsgBox("Do you want to save your changes?", vbYesNo + vbQuestion, _
    "Save Record") = vbNo Then


    Me.Undo
    End If
    End If
    Exit_BeforeUpdate:
    Exit Sub
    Err_BeforeUpdate:
    MsgBox Err.Number & " " & Err.Description
    Resume Exit_BeforeUpdate
    End Sub

    However when I add this to the subform with the datasheet view it prompts to save after each modification (which is what it is asked to do) but this is very annoying as it pops up each time u move to another record which you would expect to do in datasheet view. I have tried to only run the code on the On Close event but it does nothing.

    I would just like it to prompt to save on exit instead of after each change to the data.

    If you could help with this I would be really grateful.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You may be up against the wall here since Access saves all modified data when you try and leave the record.

  3. #3
    Astron2012 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    54
    I was hoping there would be some way around this, maybe with creating temp tables?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Using transactions may do what you want. MVP Allen Browne uses them on occasion: http://allenbrowne.com/appaudit.html

  5. #5
    Astron2012 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    54
    I think this is for use with forms

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by Astron2012 View Post
    I think this is for use with forms
    Which is what you have, right?

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

Similar Threads

  1. Prompt for a table.
    By kmcg1888 in forum Queries
    Replies: 1
    Last Post: 02-10-2012, 08:10 AM
  2. Save changes to layout prompt
    By HunterEngineeringCoop in forum Access
    Replies: 2
    Last Post: 07-07-2011, 08:35 AM
  3. Replies: 9
    Last Post: 01-20-2011, 02:22 PM
  4. Prompt on close and don't save the null record
    By hasanrazaj1 in forum Forms
    Replies: 2
    Last Post: 10-24-2010, 09:24 AM
  5. Form will not save after adding a field
    By avarusbrightfyre in forum Forms
    Replies: 1
    Last Post: 08-20-2010, 06:53 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