Exit forms without saving

Below is the code for exiting without saving. It works perfectly fine. I just want to know if I can change the MSGBOX message to something like "Are you sure you want to exit without saving?" instead of its default message - "Are you sure you want to delete this record?

and also, right now, if I click NO when I am asked if I want to delete this record, it exit the form rather than staying in the same form.
But how do I make it to STAY in the same form if I click NO.

Private Sub Command24_Click()
On Error GoTo Command24_Click_Err
On Error Resume Next
DoCmd.RunCommand acCmdUndo
DoCmd.Close
DoCmd.OpenForm FormName:="fdlgSearchPatient"
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
Command24_Click_Exit:
Exit Sub Command24_Click_Err:
MsgBox Error$
Resume Command24_Click_Exit

Sponsored Links:

Related Topics

Exit without saving Subform
I have a main form and a subform to it.
There is a command button in the main form for 'Exit without saving'. Some of the fields in the main form and subform is in required fields.

The code works perfectly fine if I have started answering some questions in the main form only but it did not work when I start to answer questions in the subform and when I try to save and exit.

It tells me that I need to answer some fields before I exit. How do I get the subform to be working?


Form not saving
I am trying to figure out why on one of my forms when saving if the user doesn't click off of the last textbox it won't save the value they entered. this is the first time I have encountered this problem. I have made many different forms and never had this issue before.


Saving Form Control Properties
I'm working on some forms that have a number of unbound toggle buttons. When the button is clicked and becomes active, the caption of the toggle button changes from "" to "X".

I'd like to be able to save the changes to the form properties on exit, but it's apparently beyond me. (Although I do have one form that manages to save the changes. But I can't figure out why or what the difference is between that form and the rest!) I've even tried opening the forms in design mode.


A2003 takes long time to save forms
I'm developing an A2003 application and making changes to forms. Whenever I save a form, it takes 5-10 seconds to save it. However, this doesn't happen with my other applications, developed on the same machine, using the same version of Access.

- I have Win XP.
- I have at least 1GB of ram.
- The MDB file is on a C: drive, which uses only 25% of the space. So at least 75% of C: is free space.
- I am linked to some other tables in another application, which resides on a network, through ODBC drivers. But no forms use these tables, and why would these tables be accessed while saving a form in design mode?
- This doesn't happen to my other Access apps. Some of which also use ODBC linked tables.
- My MDB file is in My Documents and is only 1700kb in size.
- I did do Compact and Repair several times this week, but that didn't speed up saving forms.

Any ideas how to speed up saving forms


Form Permissions
I have a Form which displays a listing of partnerships data. When I place a macro button on the form - taking the user to the underlying main record (the macro reads [PSHIPClientCode]=[Forms]![FrmPartnershipListing]![PSHIPClientCode] ) I then cannot save it any more.

Then I have to exit the form without saving it. As I now cannot edit it (because it won't save!) I decided to delete it and use a copy of it.

I have looked through the security options, everything is set to Admin.


Exit Application from Switchboard
I am using a Switchboard that contains an 'Exit Application' button. The code that the Switchboard uses for exiting the application is:
' Exit the application.

1) Case conCmdExitApplication
2) CloseCurrentDatabase
This does not actually Exit the Application as I would like. It only closes the db. I would like to close the db and exit Microsoft Access completely.


Not saving a field on exit
I'm having a minor problem. in my form, I hit the "Update" button(code below) and it works fine, but if the taxes field is Null (there are no taxes) the Total does not save when I exit the form. It does, however, when there is taxes. I just don't want my users to have to hit the update button everytime they open the form as it may cause problems


Basic Refresh Problem
I have a form that lists Orders (frmOrders). I have a button in the detail section that allows the user to open another form with some additional order details (frmOrderDetails), and they can also edit fields in that screen.

When they my Exit button on frmOrderDetails, it closes that form, and leaves you looking once again at frmOrders.

Here is my problem. A few fields appear on both forms. For instance, DeliveryDate. If someone goes into frmOrderDetails and updates the DeliveryDate field, when they click exit, I want that new DeliveryDate to be appearing on my frmOrders screen. I thought it'd be as simple as attaching the following to my Exit button:

Forms!frmOrders.Refresh

It seems to work fine for me, but I have complaints from users who say that they still don't get a refreshed screen until they exit out and open frmOrders again. Doing a .Requery definitely works, but it also undoes any sorting or filtering the user has already done, so I'd like to skip that.

If someone can tell me how to make certain that the frmOrders form is correctly being refreshed,


Filter Without Saving the Data Used
I have a search form that consists of text boxes and combo boxes. If I type 10001, for example, into the Document Number text box and click my search button, it searches and pulls up the records just fine; however, when I exit out of the form and check my table, 10001, has been added as a new record.

I do not want this to happen. I had written a vba code to set the form to read-only thinking that would help, but it hasn't.

Here's the code I used to make the form read-only and for it to open to a blank form:

[CODE]

I have a couple other forms as well, such as an add record form, an update record form, and a delete record. I made separate forms, so we could better control our documents as all are restricted with passwords, except the search record form.


Access 2010 Form close without saving
I am new into Access 2010 programming and I need your help !
I have an open form with entered data and I would like to select via an exit button a close of the form without saving the entered data (due to wrong entered data). I already did that with help of a makro, that already works but if I press that button I get a message displayed which ask me if I'm really shure to delete that file. I didn't want to have that message!

Also I would like to do this action not via a Makro, I would like to do it via VB-Code.

Could somebody please help me to realize that ?


Exit Switchboard
I have an Access 2010 Switchboard with an Exit Application demand. Is there any way that I can have an Exit software demand. That is, when the Exit button is selected on the Switchboard itcloses down Access 2010 totally, instead of simply closing down the database?


How do I capture Access DB exit event
I want to capture the "Exit" event when the user closes the DB (click on the X on top right side of the window, or use file exit


query does not work after saving
I have a query which has worked in the past. and when it finally came up with results, it hung and did not display the number of records. I tried changing the query. Before saving, I ran the query and it ran quickly, giving the expected number of records (162).

After I saved the query, it hung again when I ran it. I tried re-creating the query from scratch.

Again it ran before saving but hung after saving. Compact and repair also did not help. I am running Access 2007.


Close without saving button?
I have a form that is used to create or update a new table, and 2 buttons, save, and close w/o saving, however I can't seem to make close w/o saving work? The table gets updated as soon as focus changes. I'm not sure how to implement this,


On Tab vs. On Exit
I have a number of subs currently running in the on Exit event of several fields/forms/etc, and I'm starting to realize that's not really what I want. I'd prefer to have them run specifically if the user is attempting to tab quickly through the fields, but allow them to opt out if their navigating with the mouse.

Is there a similar sub call specifically for Tab key presses causing exits, or do I need to check for the key stroke


Quit Macro Action
You can use the Quit action to exit Microsoft Office Access 2007. The Quit action can also specify one of several options for saving database objects prior to exiting Access.


How to create relationships between tables for this situation
I am new to access and am having problems understanding relationships between tables. I tried my best to read help articles but I could not fit them into my situation.

I thank the reader for his/her patience and time.

I am trying to create a database for a hospital. Patients get admitted to the hospital, get monitored every day and then get discharged. To collect their data I made 3 tables.
1) Patient entry table - Has background details of the patient when he comes first to the hospital
2) Daily monitoring table - For entry of daily parameters (heart rate, temperature, blood pressure, etc.)
3) Patient discharge (exit) table - Has certain other parameters which are checked at his exit

Of these Tables 1 & 3 are filled only once I.e. at entry and exit while table 2 is filled daily for a patient.

Each patient is given an unique hospital ID.

I had made 3 separate forms (for each table) with the fields from the tables for data entry (as the fields will require labels to explain certain details for an inexperienced user who tries to enter data). Forms are meant for data entry. Am I right?


form and pop form saving to different records
I have created a database which 4 forms (1 main form, and 3 pop up).
In the main form, after the CutSize field has been populated through a combo box, one of the three pop-ups pop up depending on the value of the Cutsize field. The user then enters information in the pop up, that should be saved on the same record with the information from the main form.

problem: the information is saving to consecutive records, not hte same one.
the pop up saves to one record, then the main form to the record after.

is there a way to have both forms save to the same record. perhaps my database design is faulty, but I have deadlines that I must meet coming up rather quickly


form and pop form saving to different records
I have created a database which 4 forms (1 main form, and 3 pop up). In the main form, after the CutSize field has been populated through a combo box, one of the three pop-ups pop up depending on the value of the Cutsize field. The user then enters information in the pop up, that should be saved on the same record with the information from the main form.

problem: the information is saving to consecutive records, not the same one. the pop up saves to one record, then the main form to the record after.

is there a way to have both forms save to the same record. perhaps my database design is faulty, but I have deadlines that I must meet coming up rather quickly.


textbox saving details from a different form
iv got 2 linked forms, first form is either collecting or displaying customer details depending on conditions. and then using a button to go to a second form to deal with orders. everything is working fine apart from the address and postcode.

what im trying to do with the address is give the option to have a "address sent to" option on the order form. but by default using the address and postcode under the customer details.

so if the user doesnt select to send the order to a different address it uses the default.
the address textbox on the order form is retrieving the data from the customer form using the control source (=[Forms]![Customer INput1]![Address1]) however using this, it is not saving the address to the table....