How do I force "Do you want to save your changes?"

I have a form which, when edited, updates numerous fields with lookups from other documents based on LS code. However, if the user presses Escape, it closes without prompting for a save unless the user has actually typed something. Is there a way to force the prompt based on the fact that fields have been updated, even though the user didn’t type anything?

Subject: How do I force “Do you want to save your changes?”

You can add a alert in Queryclose asking them if they want to save the changes and save it programatically.

promptmsg = wk.Prompt (PROMPT_YESNO, “Save”, “Are you sure you want to Save ?”)

If promptmsg = 1 Then	

	Set doc = uidoc.Document

	Call uidoc.Save()

	Call uidoc.close		

End If

Subject: RE: How do I force “Do you want to save your changes?”

Won’t quite work. If the user has made changes in the document, and does not want to save them, they will get prompted twice, because the system prompt occurs before the QueryClose executes, and I have no way to determine if they already said No.

Subject: RE: How do I force “Do you want to save your changes?”

Declare promptmsg as a global variable and you will be able to get the value in Queryclose.

Subject: RE: How do I force “Do you want to save your changes?”

That makes absolutely no sense at all as stated.

The prompt that will occur with UI changes is the system Save Options dialog. The only way around the Save Options dialog is to use a SaveOptions field. There may be some unintended consequences, but setting SaveOptions to “1” (to force a save on close), then replicating the behavior in the QuerySave. You can set the SaveOptions to “0” in the QS and set Continue to false, which should allow a document close without further prompting. This will always treat the document as “dirty”, which may annoy your users as much as the current behavior (treating the document as “clean” unless it is manually updated).

Subject: RE: How do I force “Do you want to save your changes?”

I’ve managed to force the prompt by using the keybd_event macro to fake keystrokes, putting a space and then a backspace in the first field on the document. It always prompts for a save even if nothing’s changed, but most of the time that is appropriate in this application.

Subject: RE: How do I force “Do you want to save your changes?”

No. If I declare promptmsg as a Variant it has no value when QueryClose runs. If I declare it as an Integer, it’s always zero, regardless of whether there was already a prompt, or what the answer was.

Subject: RE: How do I force “Do you want to save your changes?”

I just tested it. It returns 1 or 0 based on users selection - Yes or no in the prompt.

What i did

Dim promptmsg As Integer in Global declaration.

In Actions added a “Save” button and in Queryclose added the same code which is in “Save” button. Added a msgbox cstr(promptmsg) in Queryclose.

When i hit “Save” button, it prompts me to save “yes or no”. If i choose yes, i get prompted 1 as the document closes. If i hit “no” i get prompted 0 as the document closes.

Subject: RE: How do I force “Do you want to save your changes?”

If I make changes on the document, then press escape, I get the system prompt "Do you want to save your changes?"If I click No, it then executes the QueryClose code, which prompts again.

Subject: RE: How do I force “Do you want to save your changes?”

Take away the prompt from Queryclose, based on the first Promptmsg selection either save the doc or leave it. I just gave you a solution, its up to you to play with it.

Subject: RE: How do I force “Do you want to save your changes?”

Maybe I’m missing something here.

In my Global declarations I have:

Dim Promptmsg As Variant

In my QueryClose I have:

If Isempty (Promptmsg) Then

	Messagebox "Empty"

Elseif Promptmsg Is Nothing Then

	Messagebox "Nothing"

Else

	Messagebox "Value " & Cstr(Promptmsg)

End If

If I make changes in the document and press escape, I get the standard “Do you want to save your changes?” message. Regardless of whether I click on Yes or No, I then get a pop-up message box that says “Empty”. It never has a value.

If I dim Promptmsg as an Integer, it’s value is always zero.

Subject: How do I force “Do you want to save your changes?”

How about forcing the user to execute a “Save” action button? If they press Escape just prompt them to use the “Save” button. Search this forum for several ways to accomplish that.