This should work. To ensure that both inserts are done, put them both into transaction (if we're talking about database tables).
>Hi,
>
>I have a situation where a record is inserted in one table and then immediately after that a record is inserted in another table where one of the fields will get a value of PK from the 1st insert. And I want to include in the second INSERT this value. But I want to be sure that VFP always stays (in terms of record pointer) on the newly inserted record (until, of course, something else occurs - like updating the table or whatever). Therefore, can I rely on VFP to stay on this newly inserted record?
>
>Here is a pseudo example of what I am doing:
>
>
>*-- Suppose that AUTO PK generation is used
>INSERT INTO TABLE1 (FLD1, FLD2) value ("Val1", "Val2")
>INSERT INTO TABLE2 (FLD1, FLD2, TBL1PK) values ("SomeVal1","SomeVal2",TABLE1.PK_VALUE)
>
>
>Please let me know what you think.
If it's not broken, fix it until it is.
My Blog