Getting asked if I want to save changes, why

I have this code and even though I am saving and closing the uidoc, I am still getting the pop up message asking “Do you want to save your changes?” (with Yes/No/Cancel options). Any ideas? Thanks much!

'Save & Exit button

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim workspace As NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim con As ODBCConnection

Dim qry As ODBCQuery

Dim res As ODBCResultSet     

Dim doc As NotesDocument

Dim id As String, psuid As String, prefname As String, acctname As String

Dim mnum As String, expdate As String

Dim desiredresult As Variant



Set workspace = New NotesUIWorkspace

Set uidoc=workspace.currentdocument

Set db = session.CurrentDatabase

’ warehouse control

Dim wh_db As New NotesDatabase("","")

Dim wh_doc As NotesDocument

Dim wh_view As notesview

Set wh_db=session.getdatabase("DDAS2/Notes","acswrhsct.nsf")

Set wh_view=wh_db.getview("CT2")

Dim c1 As String, c2 As String, c3 As String, c4 As String

Set wh_doc = wh_view.Getfirstdocument

If Not wh_Doc Is Nothing Then

	c1 = wh_doc.ColumnValues(0)

	c2 = wh_doc.ColumnValues(1)

	c3 = wh_doc.ColumnValues(2)

	c4 = wh_doc.ColumnValues(3)

End If



Set con = New ODBCConnection

Set qry = New ODBCQuery

Set res =  New ODBCResultSet

Call con.connectTo(c1,c2,c3)



If con.GetError <> DBstsSUCCESS Then

	Messagebox con.GetExtendedErrorMessage,, _

	con.GetError & " " & con.GetErrorMessage

	Goto Exit_Sub

End If



Set qry.Connection = con



Set doc=uidoc.document

Mnum = doc.Mnum(0)       

If Mnum="" Then

	Messagebox "Please enter a valid membership number."

	Goto Exit_Sub

End If



Call uidoc.Refresh

’ Dim dtToday As String

’ dtToday = Today ( )

Dim dtToday As Variant

DtToday = Today



Dim dateV As String

dateV = doc.GetItemValue("ExpDate")(0)

’ If uidoc.IsNewDoc Then

If (Cdat(dateV)) >= dtToday Then

’ If dateV >= dtToday Then

'Membership Number

’ qry.SQL = "select * from psu_mv_den_bio where memb_number = " + “” + Mnum + “” + " and memb_status_code = ‘A’ and primary_ind = ‘Y’ "

	qry.SQL = "select * from psu_mv_den_bio where memb_number = " +  "" + Mnum + "" + " and memb_status_code = 'A' "

	

	If qry.GetError <> DBstsSUCCESS Then

		Messagebox qry.GetExtendedErrorMessage,, _

		qry.GetError & " " & qry.GetErrorMessage

		Goto Exit_Sub

	End If

	Set res.Query = qry

	res.Execute

	If res.IsResultSetAvailable Then

		doc.memb_status_code = res.GetValue(182)

		Call uidoc.Save

		Call uidoc.Close

		Call workspace.ComposeDocument( "", "", "EFTDeduct" )

	Else 

		Messagebox "There was no active membership information found for this membership number, please try again"

	End If

	

	doc.expDateforExtract = Format(doc.expdate(0),"YYYYMMDD")

	

Else

	Call uidoc.Save

	Call uidoc.Close

	

	Call workspace.ComposeDocument( "", "", "EFTDeduct" )

	

	

	

End If

Exit_Sub:

res.Close(DB_CLOSE)

con.Disconnect

End Sub

Subject: RE: Getting asked if I want to save and exit, why

Let me repeat what I said in the other thread; this is not the place to do validations. The user has other ways to save besides your action button. Do validations in Querysave, that way the user can’t bypass them by Ctrl+S.

I suspect your save failed, or else there’s a way to get through your code without hitting that line. You don’t say what the exact sequence is where you get the message.

You can’t just save and close. You have to save, test whether the save worked, and then only close in that case.

Subject: RE: Getting asked if I want to save and exit, why

Thank you, Andre. My superviser actually created the code and has asked me to add to it. We have run this through debug and are getting the question of saving right at the very end of the sub. I can try moving to querysave but the database is in production right now and today is the day all the bugs are coming up. Thanks again.

Subject: RE: Getting asked if I want to save and exit, why

If you have established that the save is working, then something is happening to make the document seem to be modified after the save. Is there perhaps some Postsave event code on the form, or on a subform?

Subject: Getting asked if I want to save changes, why

Try to have your script ends like thisCall uidoc.Save

uidoc.document.saveoptions = “0”

Call uidoc.Close

Best regards,

Fadi Kiwan