>I am trying to create an array from a select and then use the values in the array in an insert statement. I read somewhere that if you create an array with a select and there is no data, the array isn;t created. Becuase of this, I added a check to _tally and created the arrays manually. Before I made the change I was getting voidarray does not exist. After my change I am getting operator/operand type mismatch. Any ideas?
>
>SELECT tpi
> SCAN
> IF tpi.creditmemo = .T.
> SELECT totaldue FROM vi INTO ARRAY voidtotal WHERE invno = tpi.ordnum
> IF _TALLY = 0
> DIMENSION voidtotal[1]
> voidtotal[1] = SPACE(1)
> ENDIF
> SELECT totalpaid FROM vi INTO ARRAY vitotalpaid WHERE invno = tpi.ordnum
> IF _TALLY = 0
> DIMENSION vitotalpaid[1]
> vitotalpaid[1] = SPACE(1)
> ENDIF
> INSERT INTO payinv (invno,custno,company,invdate,changed,totaldue,totalpaid,creditInv);
> VALUES (tpi.ordnum,tpi.custno,tpi.company,tpi.invdate,tpi.changed,tpi.totaldue+voidtotal-;
> vitotalpaid,;
> 0.00,tpi.invno)
> SELECT invpost
> UPDATE invpost SET totaldue = tpi.totaldue+voidtotal-vitotalpaid ;
> WHERE invno = tpi.ordnum
> UPDATE invpost SET totaldue = tpi.totaldue+voidtotal-vitotalpaid ;
> WHERE invno = tpi.invno
> TABLEUPDATE()
> SELECT tpi
> ELSE
> INSERT INTO payinv (invno,custno,company,invdate,changed,totaldue,totalpaid) ;
> VALUES (tpi.invno,tpi.custno,tpi.company,tpi.invdate,tpi.changed,tpi.totaldue,;
> tpi.totalpaid)
> ENDIF
>ENDSCAN
1. In your INSERT and UPDATE should you not be referencing voidtotal[1] and vitotalpaid[1]?
2. You've set the values of the arrays to SPACE(1) if not present. Should you not be using zero?
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up