473,382 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

cancel button

Hello,

Is there a way to make a kind of "cancel" button on a form?

Suppose you accidently changed or overwrote some data in a form, then I'd
like to leave this form at once and cancel any change made in this form.
Hopefully someone has a clue for me.

thanks a lot!

best regards,

martin
Feb 12 '07 #1
4 7789
The question is whether Access has already written the record to the table
or not. You can determine that very easily if you show the Record Selector
(left of form.) If there are uncommitted edits in progress, the icon in the
Record Selector will be a little pencil icon until the record is saved.

If the changes have not been saved, it's just a matter of pressing the Esc
key twice: once to undo the current field, and the second to undo other
changes to the record. If you want to do this with an undo button, use:
If Me.Dirty Then Me.Undo

If the changes have been saved, some versions of Access in some situations
will still undo the change by choosing Undo on the Edit menu. Personally, I
find this behavior really annoying, because it is inconsistent and because
it's very hard to track what actually got changed if you are trying to track
changes through events. I can't really encourage you to do this, but you
could simulate it with:
RunCommand acCmdUndo

But there's a more basic problem with placing an Undo button on a form. Say
you are part-way through entering a date and change your mind, so you click
the Cancel button. At this point, Access handles the events for the text box
you are in *before* it allows the focus to move to the command button. Since
the date is not valid - perhaps you had got as far as 2/9/ - it complains
that's not valid, and won't let you out of the box. So you backspace the
characters out. If this date is required, it still won't let you out of the
box. You can't get to the Cancel button until you enter something valid.

As you can see, a Cancel button on the form is not a good idea. Use the
Cancel button in the toolbar instead, or teach your users to use the <Esc>
key instead.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"martin" <no***@nowhere.orgwrote in message
news:45**********************@news.kpnplanet.nl...
>
Is there a way to make a kind of "cancel" button on a form?

Suppose you accidently changed or overwrote some data in a form, then I'd
like to leave this form at once and cancel any change made in this form.
Hopefully someone has a clue for me.

thanks a lot!

best regards,

martin
Feb 13 '07 #2
On Tue, 13 Feb 2007 10:05:43 +0900, "Allen Browne"
<Al*********@SeeSig.Invalidwrote:
>The question is whether Access has already written the record to the table
or not. You can determine that very easily if you show the Record Selector
(left of form.) If there are uncommitted edits in progress, the icon in the
Record Selector will be a little pencil icon until the record is saved.
------------------
>
As you can see, a Cancel button on the form is not a good idea. Use the
Cancel button in the toolbar instead, or teach your users to use the <Esc>
key instead.
I agree, Allen. And I'll take it a step further, although it is more
complex: load local work tables with all the master & child records
to be edited, bind the form to the work tables, then use OK & Cancel
to control whether they are all committed back to the main tables.
This is the only way I know of to provide a reliable overall Undo
feature.

It's easier to teach users to be careful, and also how to use the Esc
key.
Armen Stein
Microsoft Access MVP
www.JStreetTech.com

Feb 14 '07 #3
Yes, that works, Armen.

I presume you have a split database where everyone has their own local front
end, so their edits don't interfere. But if you copy the records locally and
only write them back later when the Comit button is clicked, how do you
avoid different users from overwriting each others edits?

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Armen Stein" <Ar********@R3m00v3Th1s.gmail.comwrote in message
news:ed********************************@4ax.com...
On Tue, 13 Feb 2007 10:05:43 +0900, "Allen Browne"
<Al*********@SeeSig.Invalidwrote:
>>The question is whether Access has already written the record to the table
or not. You can determine that very easily if you show the Record Selector
(left of form.) If there are uncommitted edits in progress, the icon in
the
Record Selector will be a little pencil icon until the record is saved.
------------------
>>
As you can see, a Cancel button on the form is not a good idea. Use the
Cancel button in the toolbar instead, or teach your users to use the <Esc>
key instead.

I agree, Allen. And I'll take it a step further, although it is more
complex: load local work tables with all the master & child records
to be edited, bind the form to the work tables, then use OK & Cancel
to control whether they are all committed back to the main tables.
This is the only way I know of to provide a reliable overall Undo
feature.

It's easier to teach users to be careful, and also how to use the Esc
key.
Armen Stein
Microsoft Access MVP
www.JStreetTech.com
Feb 14 '07 #4
On Wed, 14 Feb 2007 11:17:44 +0900, "Allen Browne"
<Al*********@SeeSig.Invalidwrote:
>Yes, that works, Armen.

I presume you have a split database where everyone has their own local front
end, so their edits don't interfere. But if you copy the records locally and
only write them back later when the Comit button is clicked, how do you
avoid different users from overwriting each others edits?
Hi Allen,

We typically use a separate "work" mdb, also stored locally in the
same folder as the front-end application. This avoids bloating the
application, and we often have code that automatically compacts the
work mdb whenever the application opens.

To mitigate the hassle of linking yet another MDB, we built
standardized relinking code that can automatically and silently relink
to an MDB if it is found in the same folder as the application.
Otherwise, it prompts. This allows us to have auto-linking for local
mdbs, but prompted linking for back-end mdbs on a server.

Regarding committing the records - you're right, it can be an issue.
We've found that either:

a) Last edit wins, and we have to educate the user about that. We
usually find that it would be extremely rare for two users to be
editing the same records in a real world situation.

b) Some kind of "edits in progress" flag can be set at the master
record level when the work tables are loaded up for editing. Of
course, an override capability would also be needed, adding to the
complexity.

Armen Stein
Microsoft Access MVP
www.JStreetTech.com

Feb 15 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Mike L | last post by:
I have a child form frmDataEntry call up another child form frmDealerSearch. If the user clicks on cancel on frmDealerSearch, I want to close frmDealerSearch and put the focus on txtDealerNum on...
3
by: Mvk | last post by:
Hi; I have a simple aspx form. I have put a textbox and 2 buttons on it. The textbox is linked to a requiredfieldvalidator. Click on button 1 (= ok button) = Store value in textbox in...
3
by: MB | last post by:
Hi, I am doing a project which uses asp.net to develop its forms. The form uses validation web controls to validate the data entered in text boxes. When Cancel Button is pressed which is to exit...
14
by: clintonG | last post by:
This is an appeal for peer support sent to Microsoft as will be noted in closing. The Login control does not include a Cancel button. The only option is to convert the Login control to a...
21
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on...
2
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I change the confirm box to say yes/no or default to cancel?...
4
by: MaxMax | last post by:
I have a dialog box with a Cancel button that I want to be activable with the ESC key. In the form the Cancel button is connected to the CancelButton property. Now my problem is that the OnClick...
0
by: Eraser | last post by:
Hi to all .NET guru guys... I have a problem in my delete button inside gridview. How to avoid postback on when i select cancel on confirmation message? But postback is okay on Ok confirmation....
5
by: ghjk | last post by:
I have "cancel" button in php files. I want to write common javascript function for cancel button. When user click cancel button I want to clear php form data. Is it possible? <input id="Cancel"...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.