473,396 Members | 2,081 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,396 software developers and data experts.

Close the form with out saving

JAMBAI
28
Hi,

I have a MS Access form,and its recordsource is some search query.

When I click the close button (not the X mark) what ever data I typed in the form field are saved into the database.

DoCmd.Close acForm, Me.NAME is the code behind that button click event.

Let me know how to close the form without saving the data.

Thanks
Jambai
Feb 15 '07 #1
9 13771
MMcCarthy
14,534 Expert Mod 8TB
Hi Jambai

You need to run an Undo command first as follows:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
  2. DoCmd.Close acForm, Me.Name
Mary
Feb 15 '07 #2
NeoPa
32,556 Expert Mod 16PB
It's difficult for me to test this atm (& Mary's code will work anyway :)), but try this :
Expand|Select|Wrap|Line Numbers
  1. Me.Dirty = False
  2. Call DoCmd.Close(acForm, Me.Name)
Actually, put it in the OnClose event procedure instead :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close()
  2.   Me.Dirty = False
  3. End Sub
That way it doesn't matter if the operator does use the forms x.
Feb 16 '07 #3
JAMBAI
28
Thank you so much for your responses.

I tried with Me.Undo, it worked.

Thanks
Kumar
Feb 16 '07 #4
NeoPa
32,556 Expert Mod 16PB
Nice one Kumar.
I'm not absolutely sure if that will work if/when multiple changes are made on the form before it's exited. If you find that's a problem, simply try out the Me.Dirty approach :)
Feb 16 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Nice one Kumar.
I'm not absolutely sure if that will work if/when multiple changes are made on the form before it's exited. If you find that's a problem, simply try out the Me.Dirty approach :)
I should work for any unsaved changes to the forms data.

Mary
Feb 18 '07 #6
NeoPa
32,556 Expert Mod 16PB
So it's like an UndoAll rather than an UndoLastChange then :)
Feb 18 '07 #7
MMcCarthy
14,534 Expert Mod 8TB
So it's like an UndoAll rather than an UndoLastChange then :)
Essentially if you edit a saved record it will undo all changes and revert back to the saved record.

Mary
Feb 18 '07 #8
Hi Jambai

You need to run an Undo command first as follows:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
  2. DoCmd.Close acForm, Me.Name
Mary

But if u didn't type anything and click the close command button message will appear that undo is not available right now...
Aug 30 '08 #9
NeoPa
32,556 Expert Mod 16PB
Me.Dirty tells you if you need to run the undo (Call Me.Undo seems easiest).
Aug 30 '08 #10

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

Similar topics

5
by: Harry J. Smith | last post by:
I have written a Visual Basic program that does a long calculation and writes the results to disk as it runs. If I click the Close button the window closes but the program keeps running. How can I...
1
by: Steve Jorgensen | last post by:
An Access database connected to a PostgreSQL back-end. Sometimes, when I close a form, i get a message saying that the action will reset the current code in break mode. The front-end literally...
4
by: Mindy | last post by:
I have two questions here: (1) what is the difference of close form and close table? (2) How "Prompt" works I used close form macro in my database. I hope when a user close the form, he/she will...
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...
9
by: Stan B | last post by:
I create a popup window by calling window.showModalDialog Popup window has Ok button with this code attached: === string Script = "<script language=JavaScript>" + "{" + "window.close();" +...
0
by: bmwm3 | last post by:
Hi: New to C#, I have a MainForm (parent) that can potentially have multiple child forms (in a tabbed interface). Mainform has closing event defined for "Close All" (through a menu option)...
2
by: Eric | last post by:
Hi, I have a form that requires a save button to be clicked before closing the form. I would like a msgbox to pop up when the button is not clicked before closing. Can someone show me how i...
11
beacon
by: beacon | last post by:
Hi everybody, I'm using Access 2003 and I have a form that has a custom cmdClose button. When pressed, a message box appears asking if the user wants to go back to a previous form. The problem...
32
by: Andy | last post by:
To further follow up on my last post regarding the docmd.quit vs. Application.quit using access 2007, I noticed that docmd.quit will correctly compact the database (program file) if you have the...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.