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
9 13771
Hi Jambai
You need to run an Undo command first as follows: -
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
-
DoCmd.Close acForm, Me.Name
Mary
NeoPa 32,556
Expert Mod 16PB
It's difficult for me to test this atm (& Mary's code will work anyway :)), but try this : - Me.Dirty = False
-
Call DoCmd.Close(acForm, Me.Name)
Actually, put it in the OnClose event procedure instead : - Private Sub Form_Close()
-
Me.Dirty = False
-
End Sub
That way it doesn't matter if the operator does use the forms x.
Thank you so much for your responses.
I tried with Me.Undo, it worked.
Thanks
Kumar
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 :)
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
NeoPa 32,556
Expert Mod 16PB
So it's like an UndoAll rather than an UndoLastChange then :)
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
Hi Jambai
You need to run an Undo command first as follows: -
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
-
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...
NeoPa 32,556
Expert Mod 16PB
Me.Dirty tells you if you need to run the undo (Call Me.Undo seems easiest).
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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();" +...
|
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)...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
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...
|
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,...
|
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,...
|
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...
|
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,...
| |