472,354 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 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 13598
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,511 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,511 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,511 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,511 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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.