sybasepowerbuilderdatawindow

PowerBuilder Customize Error Message on ItemChanged


On ItemChanged event of datawindow, I have to prompt a message on wrong input. The issue is: When I use messagebox(), It prompt message correctly but field is not being blank and by pressing TAB, the control is being shifted to next field. (means its accepting the wrong value by pressing TAB key again) Here is simple code for above scenario:

    if lb_error = true then
        messagebox('Info','Only Digits Are Allowed ~nAll Digits Cannot Be 0')
        this.object.payer_phone[1] =''
    end if   

Then I tried Modify property, Its working fine but Is there any possibility to change Its title and icon?? I am using following code and , Kindly help me.

   if lb_error = true then
      this.Modify("payer_phone.ValidationMsg='Only Digits Are Allowed ~nAll Digits Cannot Be 0'")
      this.object.payer_phone[1] =''
      return 1
   end if  

I am using PowerBuilder 12.0.


Solution

  • From the PowerBuilder help:

    Return Values Set the return code to affect the outcome of the event:

    0 (Default) Accept the data value

    1 Reject the data value and do not allow focus to change

    2 Reject the data value but allow the focus to change

    So in your case you need to RETURN 1 from the itemchanged event.

    Since you are handling this error in itemchanged you need to 'bypass' the itemerror event. You do this by placing a RETURN 1 there.

    By triggering the error in the itemchanged event you can create a custom error messagebox or use the system default and control the title, icon, buttons, etc.