General Question
What is the right access 2007 sql syntax for adding the last record of another table?
Im adding records programatically to several tables in an Access2007 database. I find access sql confusing, I’m used to plain simple ol’ sql dialect. So, I have the “project” table which leads all; the “samples” table and the “analysis” and “result” tables, all depending on a “relations” table, being this the one that takes the id’s from project and samples so they can be related later.
Now, all works very nicely but here’s my problem: I can create the new records in the project table, but i need to take the newly created “id” from here and create it into the “samples” and “relations” table, and I’m really confused with the sql syntax.
Im thinking:
DoCmd.RunSQL “INSERT INTO samples (id_sample) VALUES(SELECT Last(project.Id) AS LastOfId FROM project );”
would that be correct?
4 Answers
Answer this question
This question is in the General Section. Responses must be helpful and on-topic.