473,415 Members | 1,566 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,415 software developers and data experts.

Adding last record to another table with Append Query

I have four tables of different "entities". One table contains
information for "people", one for "trusts", one for "companies" and one
for "self managed super funds". Each type of entity has an autonumber
ID, "Person ID" "Trust ID" "Company ID" and "SMSF ID"

A "portfolio" table holds information about what shares, funds and
properties everyone owns. But because its organised by "PersonID" it
currently only can hold information for people, not trusts, companies
or SMSFs.

So, I've created another table which has three columns:

Entity_ID Entity_Type PTCS_ID (the last being "person or trust or
company or SMSF ID)

The Entity_ID is an autonumber, the second column specifies whether
it's a person, company, trust or SMSF and the third column is the
"Person ID" "Trust ID" "Company ID" or "SMSF ID"

With this table I can now reorganise my portfolio table to work on
Entity IDs instead of Person IDs.

Now the problem arises of how to update the Entity ID table every time
a new person, company, trust or SMSF is added.

The solution would be to write an append action query which is called
by the "After Insert" event.

The bit I'm banging my head on is how to design the query.

I basically want a query that returns the following "take the
Person/Company/Trust/SMSF ID of the record just created and the type of
entity and append this to the tblEntityIndex table."

The result would be that the tblEntityIndex table gets one extra record
with the Type and PTCS_ID of the latest person, company, trust or SMSF.

The query I've designed doesn't do that at all, in fact it appends the
Type and PTCS_ID of every person (or company, or trust, or SMSF,
depending on which query gets executed from the respective entity
subforms.)

Worse, it adds them three or four times.

For example:

There are six trusts in the Trust table, TrustIDs are 1,2,4,5,6,7
(Three was deleted)

But the records appended to tblEntityIndex are as follows:

EntityID Type PTCS_ID
628 Trust 1
629 Trust 1
630 Trust 1
631 Trust 1
632 Trust 2
633 Trust 2
634 Trust 2
635 Trust 2
636 Trust 4
637 Trust 4
638 Trust 4
639 Trust 5
640 Trust 5
641 Trust 5
642 Trust 5
643 Trust 6
644 Trust 6
645 Trust 6
646 Trust 6
647 Trust 7
648 Trust 7
649 Trust 7

Your help in this regard would be greatly appreciated!

Travis

Dec 2 '05 #1
1 4273
Answered in microsoft.public.access.queries
Dec 2 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware ...
3
by: Catherine Jo Morgan | last post by:
I have TblRoles and TblRoleTypes. The main reason for RoleTypes is to make it easier to categorize roles for people and organizations. For example, RoleType entries include Client roles, Climb...
2
by: dude | last post by:
Hi there, I have 2 tables, one with data in it, where each record has a date, this table being table01. I want to apend data to this table, but from Tabl02, but only new data, so essentially...
2
by: Robin S. | last post by:
This is an "Add product" form. The user will enter a ProductNo (catalog number), select a Product Class (from cascading combo boxes) and then click a button to create the product. When a...
6
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new...
2
by: David | last post by:
Hi, I have an order form which has a field 'ProductID'. This form has a button on each record to open a new form linked by ProductID. This new form is a continuous form and obviously, only...
19
by: davidgordon | last post by:
Hi, I need some pointers/help on how to do the following if it possible: In my access db, I have the following: Tables: Products, Sub-Assembly, Product-Pack Table, Products
3
by: john | last post by:
In my form (table A) I have subform (table B (only 2 fieds: ID and App_name) where table A -Table B are linked 1XM. To be able to add a record in the subform I want to use a lookup form since the...
69
by: kabradley | last post by:
Alrighty Guys and Gals, I have another question that I hope you all can help me with. I have a report that uses a cross-tab query as its record source. This cross-tab query is getting all of its...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.