How do I append rows to a table in Access from two related tables?
-
How do I append rows to a table in Access from two related tables? I have searched every Access forum I could find for this and I am banging my head against the wall. I have a list of tasks that are related to PERSONS, in that the task is done for the person (not BY the person), and each person requires the same set of tasks. I populated the first two tables (structure below). PERSONINFO (PersonID, PersonName) TASKS (TaskID, Task) PERSONSTASKS (PersonID, TaskID, Completed) I am at a loss as to how to populate the third. I've created the appropriate relationships between the tables. I want to populate the PERSONSTASKS table with PersonID,TaskID, Completed, so that I get: PersonID | TaskID | Completed __________________________ 1 | 1 | (yes/no) 1 | 2 | (yes/no) 2 | 1 | (yes/no) 2 | 2 | (yes/no) Remember again that the persons are not DOING these tasks; these are being done FOR them, thus I treat them like projects. I do not want the tasks entered into the PERSONSTASKS table as they are completed. I want them all there in the beginning, so I can mark them complete as they are done using a form. I've tried append queries, update queries, goat sacrifice, nothing works. I get "You are about to append 0 rows" or "You are about to update 0 rows."
-
Answer:
I wouldn't include the PersonInfo table at all, and would do something like this instead: INSERT INTO PersonsTasks ( PersonID, TaskID ) SELECT [Forms]![frm_checklist]![PersonID], Tasks.TaskID FROM Tasks; It has been a while since I've used Access though, so I'm not 100% sure you can use a form field in a select list directly like that.
desjardins at Ask.Metafilter.Com Visit the source
Other answers
By the way, here is my latest attempt at the append query (frm_checklist is where they enter a new person, I want to append the list of tasks to personstasks whenever a new record is created in the personinfo table): INSERT INTO PersonsTasks ( PersonID, TaskID ) SELECT PersonInfo.PersonID, Tasks.TaskID FROM PersonInfo LEFT JOIN (PersonsTasks LEFT JOIN Tasks ON PersonsTasks.TaskID = Tasks.TaskID) ON PersonInfo.PersonID = PersonsTasks.PersonID WHERE (((PersonInfo.PersonID)=[Forms]![frm_checklist]![PersonID])); Here I get "You are about to append 1 row." There are 31 records in the Tasks table and 14 records in Personinfo, fwiw.
desjardins
Holy crap. I owe you a beer or three.
desjardins
Related Q & A:
- How Can I Get Started As A Freelance Web Developer?Best solution by code.tutsplus.com
- How can I enter Mongo as a superuser or reset users?Best solution by Database Administrators
- How do I generate documentation for a project?Best solution by Stack Overflow
- How to make collapsible columns for a table?Best solution by Stack Overflow
- How can I print wirelessly from a laptop to a printer without a router?Best solution by answers.yahoo.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.