473,399 Members | 4,192 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,399 software developers and data experts.

How to close a form without saving changes, and without getting error msg?

TheSmileyCoder
2,322 Expert Mod 2GB
I have a form, which I open in dialog mode, and through the openArgs I set some values in the form (in a new record) thus dirtying the form.

The idea is then that the user should make a selection in a combobox and then just close the form again.

However, if you close the form without making a selection in the combobox, I do NOT want to save the record since its only half-finished. So I have simple code in the forms BeforeUpdate, to check if combobox is null, and if so, set Cancel=True (cancelling the update)

However, the user then gets a msgbox saying the record could not be saved, possible due to an error in the database. Now a msg like that is gonna freak out the standard user.

How do I prevent this error message from happening?

Other info:
Access 2003
Form is opened in dialog, in Add-Only mode.
Sep 10 '10 #1
2 4032
MikeTheBike
639 Expert 512MB
Hi

I normaly control sutch things with a 'Close' button event (ie not using the forms control box), but you could try adding Me.Undo at an appropriate point in your code, but not sure if this will cause a probelem in before update event or in a dialogue form without trying it.

Just a suggestion.

MTB
Sep 10 '10 #2
NeoPa
32,556 Expert Mod 16PB
Me.Undo should work for you Smiley, but a better way to approach this (avoiding all the related issues) would be to set the .DefaultValue rather than the .Value one. This doesn't dirty the buffer at all, yet assures that your proposed value is used in any new record if it is indeed created.
Sep 10 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Sangeetha. | last post by:
I have a datagrid with just one row. When I edit the contents of the datagrid and click on Save button (somewhere else in the form), the changes are lost. However, if I click TAB from the editable...
2
by: laks | last post by:
Hi I'm opening an aspx page with javascript: window.showModalDialog("mypage.aspx", "", "status:no"); In mypage.aspx I've got a button which shall first save the displayed record in the C# code...
2
by: ClearCut | last post by:
I have written a program in VB6 that opens an existing Word document and adds some text to the top of the document before printing it. Now I want to close the document without saving the changes. ...
3
by: kev | last post by:
Hi folks, I have a form for registration (frmRegistration) whereby i have two buttons. One is Save which saves record using the OnClick property. I used wizard to create the save button. The...
6
by: martipe1 | last post by:
I created a form with a subform, the subform has the quantity field and I created a validation rule, at table level ,for quantity greater than 0. Also in my form I have a cancel button with the...
1
by: imranabdulaziz | last post by:
Dear All, I am using sql2005. i am writing stored procedure to save various master data . I recognize master by @type (input verible) and assign it to @mst veriable then based on @mst no I...
6
by: Karl | last post by:
Hi all, It may seem like a rather odd request (or not) but I would like to be able to create a file (doc, jpg, xls or one of many other files that can be automated) on a website and stream it to...
3
by: pozze | last post by:
Hi, I've just made the change from ASP to .net. I have a file (code below) that saves a user submitted file to a MS SQL 2005 database. It collects the file name, file size, file type, and lastly...
6
by: Hulm1 | last post by:
I am looking to prevent a form closing and pop up an error message if one or more fields in a related form isnull. I have a Main Form called "Job". In this main form is a subform called "JobTask"...
4
by: sumit kale | last post by:
Hi, Can somebody help me resolve my problem ? I am getting error when calculating total using unbound textfiled in subform. I have a main form called purchase_register_master and a subform...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.