12 Aug 12 13:22
I gave you this solution in the other thread, and i tested it and i have used it and it gives you the desired result you are looking for.
i don't know if you tried it or not.. but, try it.. it won't hurt
use YourTable in 0 && Or whatever your tablename is called.
&& This will remove duplicate account in case there are dups
select Distinct AccountNo from Yourtable order by AccountNo ;
Into cursor _curAccountFields
lcCMD = 'create Table NewTable (' && assuming your new tablename is called NewTable
lcfield = ALLTRIM(TRANSFORM(AccountNo)) && Assuming the field for account is AccoutNo
lcField = STRTRAN(lcField,' ','_') && Make the spaces to an underscore
lcField = IIF(ISDIGIT(SUBSTR(lcfield,1,1)),'_','') + lcField && if numeric, put a _ in the front
lcCMD = lcCMD + ALLTRIM(lcField) + ' C(10), ' && build the statement for each field.
lcCMD = SUBSTR(lcCMD,1,LEN(lcCMD)-2) + ' ) ' && remove the last 2 delimiters and add the last ) to close
&lcCMD && execute the statement built
IF USED('Newtable') && check the cursor
CATCH TO loexp
MESSAGEBOX(loExp.Message + CHR(13) + ;
'Line: ' + TRANSFORM(loExp.LineNo))