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

Changing a field type in ObjectPal 2

Status
Not open for further replies.

Steve688

IS-IT--Management
Oct 23, 2002
34
CA
Hi,

I am currently programming an app that requires one field type to change from a datestamp to a "date" format. When I restructure the field in the table manually, it gives me the exact results I need, but I'd like to have my form do it on the fly with objectPal. Is it possible? I'm coding in Paradox 8.

Thanks in advance for any replies.

Cheers!

-Steve
 
I'd like to have my form do it on the fly with objectPal."

A form that has the table in the datamodel? Nope. Definetly cannot restructure a table from within a form that contains that table in its datamodel.

A remote table from the form? Possible, maybe, but not recommended.

Is this something that is going to have to keep happening?

What results do you see interactively when restructuring, and changing from datetime to date? Error/warning messages? Or does it just happen?



Tony McGuire
"It's not about having enough time. It's about priorities
 
Hi Tony,

I'll try to explain it:

The field is called 'EXPIRYDATE'

As a timestamp type the data is shown as: 12:00:00 AM, 12/31/2004

When I manually restructure the table and change the type to Date, it becomes: 12/31/2004 (exactly what I need)

My reasoning for changing the type to Date is because the form then compares this field in this table to a date format field in a different table, flagging if there is a difference.

When I manually restructure the table, I get a warning dialog telling me that there may be data loss if I trim the field. I click OK to continue.

I'm not sure about if it is in the datamodel or not, I don't know what that is. Would it help to see the code? There's a lot of it though.

Thanks for the help.

-Steve
 
Based on Help on Restructure:

; adjust for your table/field names

var
tbl Table
tcFlds TCursor
dynNewStru DynArray[] Anytype
endvar

tbl.attach( "restruct.db" )
tbl.enumFieldStruct( ":priv:field_struct.db" )

tcFlds.open(":priv:field_struct.db" )
tcFlds.edit()

scan tcFlds :
if tcFlds."Field Name" = "dt" then
tcFlds."Type" = "Date"
quitLoop
endif
endscan
tcFlds.endEdit()
tcFlds.close()

dynNewStru["FIELDSTRUCT"] = ":priv:field_struct.db"

tbl.restructure( dynNewStru )


Tony McGuire
"It's not about having enough time. It's about priorities
 
Tony,

Thanks! I did go looking for it in the objectpal help screens but didn't see it.

Many thanks, that will do the trick.

-Steve
 
That will NOT do the trick if the table in question is in the datamodel of the form, or otherwise 'open'.

With the form in design, go to Format | DataModel

If the table in question appears, that means Paradox has that table open whenever the form is open. In which case the Restructure operation will fail.

You need to answer this question before trying to restructure that table.

Tony McGuire
"It's not about having enough time. It's about priorities
 
No tables appear linked in the datamodel from your description above. I open and close the table appropriately within the program. I do understand what you are saying, trying to restructure while open will cause an error or table corruption.



-Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top