Conernesto
asked on
Access database relationships
I am creating a database with three tables. The names of my tables are One_tbl, States_tbl, and Two_tbl.
One_tbl has a primary field called Acode that is a primary key.
States_tbl has a field called "St" that is a primary key.
I want table Two_tbl to have all records from States_tbl filed "St" and all the records from Acode from my table One_tbl
What I want on table Two:
St Acode
AK 15(a)
AK 15(c )
AL 15(a)
AL 15(c )
The above is an example of two States AK and AL. How do I do this? Attached is my sample databaseAdjustments.accdb
One_tbl has a primary field called Acode that is a primary key.
States_tbl has a field called "St" that is a primary key.
I want table Two_tbl to have all records from States_tbl filed "St" and all the records from Acode from my table One_tbl
What I want on table Two:
St Acode
AK 15(a)
AK 15(c )
AL 15(a)
AL 15(c )
The above is an example of two States AK and AL. How do I do this? Attached is my sample databaseAdjustments.accdb
ASKER
I see that you created a Form. I need in the table name Two_tbl all records from Field St and next each St the field Acode from the One_tbl.
Just use the comboboxes to populate Two_table
ASKER
Attached is a revised version of the database. To get what I need, I created a relationship (see relationships in database tools. I then opened One_tbl, expended the first plus sign and copied the 50 St codes. I then opened the next plus sign and copied the 50 St codes. This is how I got my table two to show all the codes that I need see below sample and from attached see table two. Is there a way to do what I did without copying the fifty states into each primary key in table One?
St Acode Amount Percent
AK 15(a) 0.00
AK 15(c ) 0.00
AL 15(c ) 0.00
AL 15(a) 0.00
Test_Adjustments.accdb
St Acode Amount Percent
AK 15(a) 0.00
AK 15(c ) 0.00
AL 15(c ) 0.00
AL 15(a) 0.00
Test_Adjustments.accdb
Easy...run this Query
INSERT INTO Two_tbl ( ACode, St )
SELECT One_tbl.ACode, States_tbl.St
FROM One_tbl, States_tbl;
ASKER
I entered what you sent in SQL in a query. When I run the query the records don't get updated. I think I am doing something wrong.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Make table code works. Thank you.
Conernesto
Conernesto
ASKER
Ideally I would like that every new primary key that is added on table One is also added on table two?
Just try it...
Check my attachment
Adjustments.accdb