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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need code to Restructure Table Field Type from Form 1

Status
Not open for further replies.

elevator

Programmer
Apr 23, 2002
19
0
0
US
I have field in a table that with a numeric format. I cannot change structure of this tables because it is part of an application.

I do have an answer table that I can restructure to change the structure. I have done it manually, but I need the code to change it via a form.

I need to change a numeric type to an alpha type with a size of 20.
 
Try modifying this example to work in your situation. Note that you cannot use an alias, you must use a hard path. I haven't had coffee yet so look for typos. :)

Code:
var

tbl         Table
tcFlds      TCursor
dynNewStru  DynArray[] Anytype

endvar

tbl.attach("c:\\myPrivDir\\answer.db")
tbl.enumFieldStruct("c:\\myPrivDir\\field_struct.db")
tcFlds.open("c:\\myPrivDir\\field_struct.db")
tcFlds.edit()

;// change to alpha

scan tcFlds :

if tcFlds."Field Name" = "My Field Name"
    then tcFlds."Type" = "ALPHA"
         tcFlds."Size" = 20         
endif

endscan


tcFlds.endEdit()
tcFlds.close()

dynNewStru["FIELDSTRUCT"] = "c:\\myPrivDir\\field_struct.db"
tbl.restructure( dynNewStru )

return

Hope this helps,

Mac :)

"Strange women lying in ponds and distributing swords is no basis for a system of government" - Dennis, age 37

mailto:langley_mckelvy@cd4.co.harris.tx.us
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top