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!

Copying records via tcursor

Status
Not open for further replies.

Miros

Programmer
Jan 27, 2001
506
0
0
US
I have a script which gets a value from a field, opens a tcursor associated with one of the tables on the main form, opens a dialog style form, uses the value as a key on the tcursor, and displays the appropriate record in the form for modification (users are not allowed to change the key field from this form. When the form gets closed, the db is updated. As part of this process, I want to copy the modified record to another table as well (duplicate of the first, just no key and different sort order). I've tried tc.endedit(), tc.update(), and several other calls to attempt to copy the record. The second table is always updated with the pre-edit values from the table being edited.

Any ideas?

Will post actual code once the browser on the machine I do my databasing on is re-installed.

Rose/Miros
 
Have you tried the copyToArray and copyFromArray methods?

e.g.

var
tc1, tc2 TCursor
dyn DynArray[] AnyType
endVar

if not tc1.open("table1.db") then errorShow() return endIf ;table in the dialog form

if not tc2.open("table2.db") then ;external table
errorShow()
tc1.close()
return
endIf

tc2.edit()

if not tc1.copyToArray(dyn) then
errorShow()
tc1.close()
tc2.close()
return
endIf

if not tc2.copyFromArray(dyn)
errorShow()
tc1.close()
tc2.close()
return
endIf

tc2.endEdit()
tc2.close()
tc1.close()

; or something like that

 
After the user edits the record, use a postRecord() somewhere on the form to update the form's table BEFORE calling your code to copy the record using the tcursor.

Padraig
 
I bet the postRecord will do it, thanks!

Rose/Miros
 
postRecord from either the main form or from the dialog form doesn't do it. I still get the previous contents of the record pointed to by the TCursor tc copied into the TCursor tc2.

Rose
 
I have found that sometime TC.PostRecord() does not work, however, issue these 2 commands would usually does the trick.
EndEdit
Edit
So, before issue these commands before tc.copytoarray should do the trick

Good Luck

Joe
 
Now this is weird...

I've somehow got the updates working on the title record attached to the main record on the form, and the author record in the first panel... but not the rest!

Time to go in and poke around looking for differences in my stuff...

By the way, copying records via TCursor works fine... but it just copies the old values, not the new ones...

Rose/Miros
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top