Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 6th, 2005, 06:36 PM
Authorized User
 
Join Date: Feb 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cancelling a record entry

Hi everyone.

Since I started to program with Access I've always had a problem cancelling a record. For instance I have a OK and a Cancel button on a form. From the user point of view he/she has the impression that clicking OK will close the form and save the data.

On the other hand clicking Cancel should close the form and discard the data entered. I understantand that the:

DoCmd.RunCommand acCmdUndo

is very useful in this case. But sometimes the data can be commited to the table (maybe it was saved because there is a subform in the main form and clicking in the subform saves the data in the main form).

I suppose the Dirty property of a form can hint as to if the entry can be undone or not.

Anybody has experience with using a Cancel button on a form and make it work like the user expect it. Care to join this interesting thread? I am sure many people can benefit for this conversation unless it is me that doesn't understant a thing!!!

Daniel
__________________
Daniel
 
Old March 6th, 2005, 07:02 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Daniel,

Check out in Visual Basic Help - Rollback. It has some sample code that you might be able to use.

Kevin

dartcoach
 
Old March 9th, 2005, 10:13 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

I have on many occassions heard that if you want to offer this kind of functionality you need to use unbound forms and manually do the record updates in your code.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old March 9th, 2005, 01:12 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I concur with rjweers.

I would use unbound forms and then send each update seperately. This is quite easy.

Create an unbound form.
Use wizards and code to populate your combo boxes and other controls, and use data validation etc.
Then have a button to update, which can also be on other events. Send the data from the controls to the requisite table(s) on this event.
Then discard if the discard or close button is clicked (discard would be to close and reopen the form, thus resetting the controls, or by substituting the values in the controls with default values.)

I think this is the thing to do rather than risking lock issues with a rollback.



mmcdonal
 
Old March 9th, 2005, 05:44 PM
Authorized User
 
Join Date: Feb 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi. Thanks for your great input about this problem. Hum, populating a form solely with vb can be tedious isn't it? I will surely try with a small project to see what the code would look like.

Obviously cancelling a record would then be extremely easy wouldn't it?

So to save the record you would need to open a tabletype recordset and loop through each value the user entered and write them in the table (and update it of course).

What if I want to give the user the possibility to browse the records. Would you use the same approach. I would create a bound form and make everything read-only.

Well food for thoughts. Thanks again.

Daniel
 
Old March 9th, 2005, 05:48 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Daniel,

Actually, it is pretty easy. Create a blank form, add some text boxes or combos that are unbound. Once, the user has input all the data, use a command button to verify the data and if it meets your criteria, create an SQL statement to insert into your table.

Kevin

dartcoach
 
Old March 9th, 2005, 11:31 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

And it can be even easier...

Go ahead and create the form bound (use the wizard if you like). That will give you all the fields for dragging from the field list. Then just remove the Data Source for the form. After that all you have to deal with is fetching the record(s) and populating the form. Then editing the data and saving it.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old March 9th, 2005, 11:44 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

I agree Randall. I hadn't thought of going ahead and using the wizard, then taking out the data source.

Good job!

Kevin

dartcoach
 
Old March 10th, 2005, 11:53 PM
Authorized User
 
Join Date: Feb 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Humm That sounds like a great way to add data in a table with a form and allowing to cancel an entry.

I made a little research in the Online help and I came across the INSERT INTO (which is nothing else than an append query).

That is the approach you suggest right? So is a user click Cancel after starting to type data is is very easy to clear all the controls and reset the form.

I wonder if these principles are easy to implement when there is a subform included in the main form.

I will need to make some test. Wanna thanks every one for their input in this little thread and hopefuly other will benefit from your experience.

Daniel





Similar Threads
Thread Thread Starter Forum Replies Last Post
I want to display record number in data entry form markw707 Access 5 August 28th, 2014 12:08 PM
cancelling close form rashi Access 2 October 12th, 2007 08:49 AM
Tracking record entry by date hikinfool Access 1 August 9th, 2006 09:42 PM
Need to dup a whole record in a data entry form markw707 Access 4 August 29th, 2005 10:09 AM
New Record Data entry one form lgpatterson Classic ASP Basics 1 February 8th, 2005 12:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.