Valid firing twice

Post Reply
Colin Haig
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Valid firing twice

Post by Colin Haig »

Hi All

I have moved to harbour from xharbour but have found a problem with a valid firing twice - the problem does not occur with xharbour.

The last valid after selecting YES in the MsgYesNo - saves the invoice but the MsgYesNo re appears

Code: Select all

   REDEFINE GET oInvc:subtotal ID EditSubTtl      of oDlg UPDATE   picture '999999.99' COLOR GETCOLOR   valid(lfSetTotal(oInvc,nGstRate,oDlg),TRUE)
   REDEFINE GET oInvc:invgst ID EditGST           of oDlg UPDATE   picture '999999.99' COLOR GETCOLOR   valid(lfSetTotal(oInvc,nGstRate,oDlg),TRUE)
   REDEFINE GET oInvc:invtot ID EditTot           of oDlg UPDATE   picture '999999.99' COLOR GETCOLOR ;
            valid(if(lQuoted,if(oInvc:subtotal == 0,(oInvc:subtotal := oInvc:invtot - oInvc:invtot/nDivisor,oInvc:invgst := oInvc:invtot/nDivisor,oDlg:Update()),),),;
                  if(MsgYesNo('Save Invoice'),(SaveRec(oInvc,oDlg,oCode,oTmsht,oEmpRate,oEmp,oEmpCost,oJbStck,oSundry,oJb,oPoitms,lSuper,cPath),;
                  oBtn3:Enable(),oBtn4:Enable(),oBtn5:Enable(),oBtn6:Enable(),lNew := FALSE,oJbNo:Disable(),oDlg:aControls[2]:SetFocus()),),TRUE)  // this valid fires twice
   
   REDEFINE GET oInvc:invnotes  MEMO ID EditDet   of oDlg UPDATE COLOR GETCOLOR

 
Cheers

Colin
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Valid firing twice

Post by Antonio Linares »

Colin,

Please replace:

oDlg:aControls[2]:SetFocus()

with

oDlg:oJump := aControls[2]
regards, saludos

Antonio Linares
www.fivetechsoft.com
Colin Haig
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: Valid firing twice

Post by Colin Haig »

Hi Antonio

I tried that but got the following error

ime from start: 0 hours 0 mins 16 secs
Error occurred at: 02/11/2014, 07:36:08
Error description: Error BASE/1003 Variable does not exist: ACONTROLS

Stack Calls
===========
Called from: input6.prg => (b)INPUT6( 372 )
Called from: .\source\classes\TGET.PRG => TGET:LVALID( 1203 )
Called from: .\source\classes\CONTROL.PRG => TGET:FWLOSTFOCUS( 1138 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1708 )
Called from: .\source\classes\TGET.PRG => TGET:HANDLEEVENT( 588 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3236 )
Called from: => SYSREFRESH( 0 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:KEYCHAR( 829 )
Called from: .\source\classes\TGET.PRG => TGET:KEYCHAR( 1117 )
Called from: => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1733 )
Called from: .\source\classes\TGET.PRG => TGET:HANDLEEVENT( 588 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3236 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE( 1003 )
Called from: main.prg => MAIN( 177 )

So I tried oDlg:oJump := oDlg:aControls[2] ( I thought aControls was a property of the dialog)

but I still go an error

ime from start: 0 hours 0 mins 16 secs
Error occurred at: 02/11/2014, 07:39:44
Error description: Error BASE/1005 Message not found: TDIALOG:_OJUMP
Args:
[ 1] = O TDIALOG

Stack Calls
===========
Called from: => __ERRRT_SBASE( 0 )
Called from: ../../../tobject.prg => TDIALOG:ERROR( 0 )
Called from: ../../../tobject.prg => (b)HBOBJECT( 0 )
Called from: ../../../tobject.prg => TDIALOG:MSGNOTFOUND( 0 )
Called from: ../../../tobject.prg => TDIALOG:_OJUMP( 0 )
Called from: input6.prg => (b)INPUT6( 372 )
Called from: .\source\classes\TGET.PRG => TGET:LVALID( 1203 )
Called from: .\source\classes\CONTROL.PRG => TGET:FWLOSTFOCUS( 1138 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1708 )
Called from: .\source\classes\TGET.PRG => TGET:HANDLEEVENT( 588 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3236 )
Called from: => SYSREFRESH( 0 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:KEYCHAR( 829 )
Called from: .\source\classes\TGET.PRG => TGET:KEYCHAR( 1117 )
Called from: => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1733 )
Called from: .\source\classes\TGET.PRG => TGET:HANDLEEVENT( 588 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3236 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE( 1003 )
Called from: main.prg => MAIN( 177 )

Cheers

Colin
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Valid firing twice

Post by Antonio Linares »

Colin,

My mistake. Please try this:

oInvc:invtot:oJump := oDlg:aControls[2]
regards, saludos

Antonio Linares
www.fivetechsoft.com
Colin Haig
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: Valid firing twice

Post by Colin Haig »

Thanks Antonio

I tried setting focus to a button on the buttonbar and this seemed to fix the issue - I will try the code you suggested.


Cheers

Colin
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Valid firing twice

Post by Antonio Linares »

Colin,

The VALID code execution is related to the lost of focus sequence, thats why we have to be carefull not to interfere in the process.

Using oJump we wait until the loosing/ganning focus secuence is complete.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply