1. GH kumar
  2. PowerBuilder
  3. Monday, 12 February 2018 05:35 AM UTC
hai experts
i add a datawindow name dw_1 and dataobject = d_test to u_cst_test5 useroject of advguisample.pbl
and created a event closequery and event id pbm_closequery and add following event
dw_1.AcceptText()
IF dw_1.ModifiedCount() > 0 or dw_1.DeletedCount() > 0 THEN
    IF MessageBox("Save Changes", "Would you like to save your changes before you exit the                        window?", Question!, YesNo!, 1) = 1 THEN
        Return 1
    End IF
End IF 
when i run the application and made changes and close the tab without save it closes without executing above code ;does anyone suggest where is the fault and how to correct it?  i debugged but cannot open debug window when i close the tab. i am using Powerbuilder classic 12.5 version
regards
kumar
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 12 February 2018 14:50 PM UTC
  2. PowerBuilder
  3. # 1

Hi Kumar;

  This example logic has a major flaw in it. The AcceptText () method return code is not checked. If you only update one column and it is in error, then the counts would be zero. The logic flow should be ...

Int  li_rc

li_rc = DC.AcceptText ()

IF  li_rc = -1  THEN

    DC.SetFocus ()

    MessageBox (" Data Errors ", " Please correct " )

    Return -1

else

  IF ModifiedCount > 0 ....

 

HTH

Regards ... Chris

Comment
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Monday, 12 February 2018 12:47 PM UTC
  2. PowerBuilder
  3. # 2

Why not trigger your userobject event from the window's closequery event?

Comment
  1. GH kumar
  2. Tuesday, 13 February 2018 06:03 AM UTC
hai kevin



yes i can trigger userobject event from the window's closequery event, but in advancedgui sample programs, we can close userobject before main window close. then triggering userobject event has no logic. any other possibilities?



regards



kumar



 

  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 12 February 2018 06:42 AM UTC
  2. PowerBuilder
  3. # 3

Closequery is a window event. If you add it to another type of object, it isn't going to be triggered.

Comment
  1. GH kumar
  2. Monday, 12 February 2018 10:27 AM UTC
thank you so much for the information and response sir,



in order to achieve the result i put the following code in uo_tabcontrol tabclosed event of the w_main window





If isvalid( iuo_1) then

   iuo_1.dw_1.AcceptText()

   IF  iuo_1.dw_1.ModifiedCount() > 0 or  iuo_1.dw_1.DeletedCount() > 0 THEN

      IF MessageBox("Save Changes", "Would you like to save your changes before you exit the   window?", Question!, YesNo!, 1) = 1 THEN

         Return 1

     End IF

   End IF 

End if 



when i compile i got error Return expression in subroutine



can you give me a clue about error in above code  or any event i can put the above code?



regards 



Kumar

  1. Helpful
  1. Govinda Lopez @Appeon
  2. Monday, 12 February 2018 18:22 PM UTC
Hi Kumar,



 



You are returning a value where the subroutine is set as (None)



 



Regards,

  1. Helpful
  1. Lars Mosegaard
  2. Tuesday, 13 February 2018 00:36 AM UTC
For tab pages you can use the selectionchanging event and return 1 if acceptext() returns -1 or user wants to stay on tab page before closing after your messagebox.



I don't believe there is a built in way of "closing" a tab page like a window has, but if you have a script that closes a tabpage, you need to ask the question beforehand.



You still need the window closequery event script. 

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.