![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
I open the tcursor, create a record and set the new key, then open the form on that new record. |
#4
| |||
| |||
|
|
So I'm a bit stymied. I've been trying for a few hours now to set a new record's key field to an externally generated value. I've got a table in a form that has AutoAppend on. I figure I can use the record object's CanDepart method and set the key in there, then doDefault. So I attach a TCursor to self to set the key field for the record (can't do it through the UIObject, b/c the key field is not available from the form)-- but the TCursor attaches to the last record, instead of the new record I'm editing. I've also tried this in action by catching DataPostRecord and DataUnlockRecord, catching DataInsertRecord instead and setting the key field then, and doing most of these in the form prefilter. None seem to work. Everything seems to get the TCursor attached to the prior record, as if the new record hadn't been created yet. It hasn't been posted, obviously -- but I can't post it without the key field. How exactly am I supposed to assign a key value to a new record? I've considered making the key non-required, then forcing a post on depart and setting the key there, but that seems sloppy. |
#5
| |||
| |||
|
|
George, have you tried to use dmPut(...) to set the not available key-value? Egbert, 23:30 in Spain |
#6
| |||
| |||
|
| Writes data to a table in the data model. |
|
"Egbert Babst" <EgbertBabst (AT) BabstSoft (DOT) com> wrote: George,you have you tried to use dmPut(...) to set the not available key-value? Egbert, 23:30 in Spain No, I sure haven't. I'm not sure exactly how that would work; could you explain a little more for me? |
#7
| |||
| |||
|
|
George, if you have a form with your table in the datamodel (if you have an uiobject bound to the table you'll find this table in the datamodel) you can access all fields of the table even if they are not show in any uiobject. |
#8
| |||
| |||
|
|
Did a little experimenting to figure some of that out, and sure enough, it seems to work. Acts on the new record instead of the last posted. Do you have any idea why it would work with this, but not by attaching a TCursor to the UIObject? It's confusing to me, because both attaching the TCursor and using the dmPut method are supposed to reference the current record from the UIObject, but the two methods are coming up with two different records. |
#9
| |||
| |||
|
|
The other thing you can do is put the key field on the form (in the same record object as the rest of the fields from the table), make it invisible and operate on it like any other field. Liz |
#10
| |||
| |||
|
|
Thank you mountains for your excellent explanation as to the cause of the problem -- it's exactly what I was looking for. I find that knowing the cause of the problem is far more useful than just being able to work around it -- and far more difficult to figure out, too :-) |
![]() |
| Thread Tools | |
| Display Modes | |
| |