473,320 Members | 1,839 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,320 software developers and data experts.

Exit without saving

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 following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdCancel_Click() 
  2. On Error GoTo Err_cmdCancel_Click 
  3.  
  4.  
  5.    If Me.Dirty = True Then
  6.     'Undo changes: 
  7.     DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, ,   acMenuVer70 
  8.     'Close form: 
  9.     DoCmd.Close 
  10.    End If
  11. Exit_cmdCancel_Click: 
  12.    Exit Sub 
  13.  
  14. Err_cmdCancel_Click: 
  15.    MsgBox Err.Description 
  16.    Resume Exit_cmdCancel_Click 
  17.  
  18. End Sub 
  19.  
but if I click on the cancel button, I get a message box with the validation text and I cannot exit the form.

Any hint?

Thanks,
Mar 28 '07 #1
6 3439
MMcCarthy
14,534 Expert Mod 8TB
Have you created a default value on the field in the table. Is it set to 0?
Mar 29 '07 #2
Have you created a default value on the field in the table. Is it set to 0?
No, there is no default value.

Thanks
Mar 29 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
No, there is no default value.

Thanks
It seems like the record is being saved even though you are undoing changes. Set one of the tables fields to required. This way it won't try to save the record if no data is in this field.
Mar 29 '07 #4
It seems like the record is being saved even though you are undoing changes. Set one of the tables fields to required. This way it won't try to save the record if no data is in this field.
I changed the quantity to required, this field is within the subform and I still receive the same validation text message after I click on the cancel button
Mar 29 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
I changed the quantity to required, this field is within the subform and I still receive the same validation text message after I click on the cancel button
I meant one of the other fields in the table where the quantitiy is stored.

If that doesn't work try changing the validation to form level instead of table level and see if that makes any difference.

Mary
Mar 29 '07 #6
I meant one of the other fields in the table where the quantitiy is stored.

If that doesn't work try changing the validation to form level instead of table level and see if that makes any difference.

Mary
I think the best option is to change the validation at form level.

Thanks
Mar 30 '07 #7

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

Similar topics

10
by: JKop | last post by:
An excerpt from the Standard: 4 Calling the function void exit(int); declared in <cstdlib> (18.3) terminates the program without leaving the current block and hence without destroying any...
7
by: Darklight | last post by:
if the exit() function is contained in stdlid.h why if i remove the above header file the exit function still works and i can still compile program without any error messages using cc file.c if i...
1
by: Ioannis Vranos | last post by:
I am currently reading a chapter involving multithreading, and some sample code calls Environment::Exit() to terminate the application with all threads. What is the difference from...
6
by: Mark Denardo | last post by:
My question is similar to one someone posted a few months back, but I don't see any replies. Basically I want to be able to have users upload photos and save them in a database (as byte data)...
3
by: Lloydm | last post by:
I built a timesheet and finally got all my functions working. Iv'e searched through the vb forum but had no luck finding a "print job" script. After saving file and before exit, I would like a...
2
by: Matuag | last post by:
Hi All, I want to create following command buttons on a Form which users can edit. Save ( Save Changes made) Cancel ( Undo data changes) Exit ( Close form) I am using Macros for each of...
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...
11
by: yawnmoth | last post by:
To quote from <http://php.net/function.include>, "Because include() is a special language construct, parentheses are not needed around its argument. Take care when comparing return value." ...
11
by: Rahul | last post by:
Hi Everyone, I have seen code in different styles like main(argc,argv) int argc; char **argv; { if(argc != 2) exit(1); else exit(0);
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.