Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In a recent thread I was advised to 2

Status
Not open for further replies.

Phil Thoms

Programmer
Oct 31, 2005
245
GB
In a recent thread I was advised to use the crosstab file VFPXTAB which works beautifully for all of my data. However it inserts 'C_' in front of the fields across the top from right to left, eg the account numbers now look like C_1001 instead of 1001. All I would like to do is change them to _1001 etc rather than have the letter C. I realise this is inserted because it is a character field in my original database, so how can I alter this part of the program without upsetting things.
Hope it makes sense and thanks.
 
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

Select _curAccountFields

TRY
lcCMD = 'create Table NewTable (' && assuming your new tablename is called NewTable
SCAN
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.

ENDSCAN
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
SELECT Newtable
BROWSE
ENDIF

CATCH TO loexp
MESSAGEBOX(loExp.Message + CHR(13) + ;
'Line: ' + TRANSFORM(loExp.LineNo))
ENDTRY

Ali Koumaiha
TeknoSoft Inc.
Michigan
 
Why do you need certain field names? If you bind a cursor or table to a gried, you can set each grid column header caption as you like.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top