Cancel form changes

N

Naz

Hello

I have a form which records nil returns (no absense) for staff absences. The
form opens, created a new record, and it automaticall fills in the person
team based on user. There is a calender button to allow them to choose the
week end.

There is a sub form that shows all the past returns that have been done,
linked by team to the main form. As soon as a new record is created a new
entry showing the team is created in the subform.
But if the user cancels the entry by clicking the close button, the form
closes but still stores the team name in the sub form with no week as none
was selected.
The problem occurs every time you go to view past nill returns, or go in and
then not actually enter a week.

How can i create a proper cancel button, so that when it pressed no new
record is created in the sub form, and it the form then closes.

All help is appreciated.
 
S

stumac

Actually tried that and it didn't undo the Subform - you have to setfocus to
the subform and then undo the changes there: for example -

Me.subformname.SetFocus
DoCmd.RunCommand (acCmdUndo)

This gives you a warning about deleting a record so you may want to turn the
warnings off first.

Stu
 
N

Naz

Hi

I tried this but it didn't work it gave an error message that the command
was not available, maybe it saves the record on entry thereby not allowing it
to undo or something.

Any more ideas?
 
R

Rick Brandt

Hi

I tried this but it didn't work it gave an error message that the
command was not available, maybe it saves the record on entry thereby
not allowing it to undo or something.

Any more ideas?

Canceling changes in a form/subform setup is a losing proposition. Why
do you think you need this? The vast majority of Access applications do
not provide this functionality.

Better would be to either...

Lock out edits by default and then provide a button to unlock the
record. This eliminates accidental changes because the user has to
explicitly indicate their intent to change the record by pressing the
button.

Set up a system that saves an archived copy of the data prior to making
changes so that the archive copy can be used should the record need to be
changed back. An audit trail could be similarly used.
 
N

Naz

Hi Rick

Want I want feels pretty basic, that is to leave a form without making any
changes to it.
But the subform keeps on taking on the team name value from the main form
when closing.

I want a cancel button that leaves the form/subform untouched.

Can you help Rick?
 
R

Rick Brandt

Hi Rick

Want I want feels pretty basic, that is to leave a form without making
any changes to it.
But the subform keeps on taking on the team name value from the main
form when closing.

I want a cancel button that leaves the form/subform untouched.

Can you help Rick?

As I stated, this is difficult in a form/subform setup because each form
is saved as soon as you move focus to the other.

Are you saying that data is changed/saved even when the user does nothing
but navigate to a record? If so, then you have a code or macro that is
changing the data. There is nothing about simply viewing a record that
should cause any changes to be written.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top