C
Carl Colijn
Hi all,
I have a master table for which each record must have multiple calculated
result records in a specific result table. These records are linked via an
autonumber primary key in the master table. The master records are shown
via a bound form in continuous view (sp? I'm using the Dutch Access
version...).
The solution I came up with so far is to use the form's AfterUpdate event to
programmatically create/update the result records for the updated master
record. However, since I need to specify the foreign key in the result
record (the tables are linked via a cascading delete relationship), I need
to know the used value for the primary key in my master record. I have a
control on my form that is bound to the primary key field, and the number in
this control is always correct. However, if I use the form's Recordset
property to get to the used primary key value, the value is not correct.
Example behaviour:
1- open the form
2- insert a new record
3- put the focus on another record
4- AfterUpdate event fires: Control's value equals Recordset's value
5- insert another record
6- put the focus on yet another record
7- AfterUpdate event fires: Control's value doesn't equal Recordset's value;
Recordset points to the record selected in step 3
I know you can use Recordset.Bookmark = Recordset.LastModified when you add
records programmatically, but when using this tactic in the AfterUpdate
event, it just puts the form's focus on the record selected in step 3.
I'm creating the result records in a separate routine that has as it's sole
parameter a recordset pointing at a master record (I need to call this
routine from some other places as well). I know I can write a workaround to
also specify the correct master's primary key value as a parameter to the
routine, but does anyone have a more elegant solution to this problem?
Kind regards,
Carl Colijn
I have a master table for which each record must have multiple calculated
result records in a specific result table. These records are linked via an
autonumber primary key in the master table. The master records are shown
via a bound form in continuous view (sp? I'm using the Dutch Access
version...).
The solution I came up with so far is to use the form's AfterUpdate event to
programmatically create/update the result records for the updated master
record. However, since I need to specify the foreign key in the result
record (the tables are linked via a cascading delete relationship), I need
to know the used value for the primary key in my master record. I have a
control on my form that is bound to the primary key field, and the number in
this control is always correct. However, if I use the form's Recordset
property to get to the used primary key value, the value is not correct.
Example behaviour:
1- open the form
2- insert a new record
3- put the focus on another record
4- AfterUpdate event fires: Control's value equals Recordset's value
5- insert another record
6- put the focus on yet another record
7- AfterUpdate event fires: Control's value doesn't equal Recordset's value;
Recordset points to the record selected in step 3
I know you can use Recordset.Bookmark = Recordset.LastModified when you add
records programmatically, but when using this tactic in the AfterUpdate
event, it just puts the form's focus on the record selected in step 3.
I'm creating the result records in a separate routine that has as it's sole
parameter a recordset pointing at a master record (I need to call this
routine from some other places as well). I know I can write a workaround to
also specify the correct master's primary key value as a parameter to the
routine, but does anyone have a more elegant solution to this problem?
Kind regards,
Carl Colijn