Link to home
Start Free TrialLog in
Avatar of Andy Brown
Andy BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Adding a cancel function to a MS Access, settings form

I have an Access database, containing a single table that has all of the settings needed for the application.  This table has several categories (Reports, User preferences etc).

Administrators are able to go into a form and make changes to those settings as required.  However, if they make a mistake and wish to cancel those changes - they need a clean route to reverse.  I am currently using a temporary table, which is OK, but I want to know if there is a better way that doesn't evolve copying data across to the temporary table first.  

I was thinking of something such as setting the forms recordsource when it is opened to a clone of the actual live table but have never worked with clones, so don't know if; a: it's possible or, b: it's a good way to do it.

As always - I'm open to suggestions and any guidance is greatly appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
An alternative, assuming you only have one table is to use the before update event to confirm the data save:
Private Sub Form_BeforeUpdate(Cancel as Integer)
       If msgbox ("Do you really want to save these changes?", vbyesNo) <> vbyes then
              Cancel = true
               Me.undo
               MsgBox "Changes cancelled"
      else
            MsgBox "Changes saved"
      end if
End Sub

Open in new window


The advantages of the temp table method over this are that it is more forgiving, and it works well if you have related tables with child records.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Andy Brown

ASKER

Thanks guys - I should have mentioned that it is running on a continuous form - so there are multiple entries.  But, upon further research, it still looks like the original idea of using a temporary table is the best one.

Thanks again.