DMG -
What you are asking is to at run-time determine if the UUT_DATA record already exists. If it exists, acquire the primary key value in the UUT_DATA table for the record and assign it as the foreign key value for the UUT_RESULT. If it does not exist, create a new record in the UUT_DATA and use it as the foreign key value for the UUT_RESULT.
If the database that you were using supported complex stored procedures that can use IF statements (Access does not) the stored procedure could only log the UUT_DATA record if necessary, the UUT_RESULT statement would set its foreign key to the UUT number value directly.
Since TestStand 2.0 does not allow you to set a primary key value directly(TS 3.0 or 3.1 does), you would have to write to the primary key column like any other column, using an expression. The value written is just not available as a selectable foreign key for other tables.
Since stored procedures that use IF statements are not available to Access users, you need to conditionally create the UUT_DATA record. One way would be to use some external steps to query the UUT_DATA to determine if the record already exists. You would have to do this in the process model prior to logging the UUT results. In the database logging configuration, you would conditionally log the UUT_DATA statement using a precondition expression. The UUT_RESULT table would have to write its foreign key for the UUT_DATA table by value instead of referencing the primary key column from the UUT_DATA logging statement.
Scott Richardson
https://testeract.com