Using Keys From One Table To Another

Mar 21, 2013

I am absolutely new to Access. How do I put the primary key from one table into another table?

View Replies


ADVERTISEMENT

Tables :: Multiple Parents Table Linked To Child Table - Primary Keys

May 28, 2015

I have a table for a multiple parents linked to a child table. I need to figure out a way to only allow 1 parent to be coded as primary, 1 as secondary, and then the rest as other... I thought about making Primary/Secondary/Other a primary key. But then I can only have 1 other. I would have to make a finite number of parents that could be entered and I want an infinite number.... My end goal is to have a report that only has a primary and second parent on it, but the rest of the parents still exist in the table...

*Child_ID
Parent_First_Name
*Primary/Secondary/Other

View 8 Replies View Related

Two Foreign Keys In One Table.

Apr 20, 2006

I'm not new to access, and I understand normalization at pretty much all its levels, but right now I'm curious about a situation that I have just come across. The first time I've been in something like this, so I thought I would ask.

This is the setup.

I have employees. They are apart of a shift and a budget. Shifts and budgets are completely independent of each other.

The database needs to keep track of shifts and budgets over time. Therefore, 1 to many relationship to shift table and budget table.

But, the database also needs to keep track of attendance. And the user wants attendance tracked by Shift and Budget.

Shift and budget are completely independent of each other.

Currently, I have the relationships set up like this.

Employee (1) ---(Many) Budget (1)------(Many) Attendance
Employee (1) ---(Many) Shift (1)--------(Many) Attendance

When a new attendance record needs to be added, both the key to the budget and shift are added to the attendance table. The key chosen is dependant onthe Employee chosen, and whether the budget and shift are the CURRENT budget and shift that the employee is apart of.

I thought of running a query showing budget and shift by date descending, so that the latest budget / shift would be displayed, and thus the most current (SUPPOSEDLY) But, if a user put in a different date, or screwed up on the date, then the incorrect shift and/or budget would be displayed.

Date stamping an entry was an option, but there needed to also be a user entered date as well, to specify WHEN a user began working in that specific budget / shift. Therefore two date entries would be required. Duplicate entries in most cases.

I therefore decided to go with a true/false yes/no checkbox. Where the current budget or shift would be checked, and all non current ones would be unchecked (false).

Currently, this is how the systems works. And it works well. But it is dependent on some form code I created to set the yes/no checkbox to true/false depending on the situation.

I DON"T like doing this. Am I missing a way to do this "correctly" where by Access would do this "automagically" instead of via my trick.

The ONLY issue really, is that when a new attendance incident occurs, the user needs to put in the incident to the approbriate shift / budget. And if the current shift / budget could automatically be displayed without user intervention (IE user has to pick the shift / budget from drop down box after looking up info etc etc) since the current information SHOULD be known.

I've never done a table setup where two foreign keys are the many side of the relationship in a single table.

It is currently working fine, and seems to do well, but I wanted to make sure with others who might have had this experience. And also, any "advice" / "cautions" for this kind of situation so I don't step into it deep and have to fix it later.

View 14 Replies View Related

Composite Keys For Table?

May 12, 2005

I need some help with developing a certain aspect of a db. I need to track the equipment list of clinics. The equipment list doesn't really change (it has 5 possible values though each clinic may only have one to all 5 of them). The db is also to track who the manufacturer is.

I was originally going to do a three piece composite key consistenting of the clinic id, the equipment id and the manufacturer id with quantity as the non pk field. Or the other possiblility that I can see is just using an autonumber as the pk with clinic id, equipment id, and manufacturer id as fk's with qty as the non-key field. So what do you think? If you can put in explanation why your suggestion would work, that would be appreciated as I'd like to increase my knowledge base on this stuff.

If I haven't made my problem clear, I'm quite willing to provide more info.

Thanks,

scratch

View 5 Replies View Related

Table With Two Foreign Keys?

Oct 5, 2015

Can a table have two foreign keys?

View 1 Replies View Related

Tables :: Two Primary Keys Link To Another Table?

Aug 18, 2014

So, I have two Primary Keys in my table, how then do I link another tables to it?

tblAdmissions
PatientID Number Primary Key
Visits Number Primary Key

tblRoomPhoneNumbers
PhoneID AutoNumber Primary Key

View 3 Replies View Related

Table Allowing Duplicate Primary Keys

Jun 13, 2013

I've set up a table with 2 primary keys but it is allowing me to input the same combinations twice!

View 4 Replies View Related

One Primary Key In One Table Linked To Two Foreign Keys In Two Different Tables!!!

Sep 22, 2007

Hi there,

I am trying to model my database to create relationships between different tables in my database. During the process of doing so I ended up having one primary key in table A linked with to foreign keys in two different tables ( table B & table C) and both of those two table are junction tables to break out many to many between many other tables

Now for some reason!!! I feel that there is something wrong with my logic mapping and modeling of the relationships between tables due the fact of having one primary key linked to two foreign keys in two different tables :(

Is my intuition is right? should such case be considered as indicative of wrong modeling of relationships between tables in a single database
And if so what is the disadvantages of that link (talking down the road) when the database if fully populated? :confused:

By the way I am new member and new to database, so please take it easy on me :o

Many thanks

View 2 Replies View Related

Tables :: One Primary Key To Multiple Foreign Keys In The Same Table?

Aug 29, 2013

Right now, I have 4 related tables. There's a table with companies, one with people involved with companies, a table linking the two by having foreign keys of the company number and people names, and a table that indicates directors and their alternates.

Since there's a one-to-many relationship for companies/people to company-peopleID (A person can run multiple companies, a company has multiple directors, it's easier this way), a person's name can appear multiple times, as can a company, within that table.

In a company, a director may or may not have 1 and only 1 alternate director to him/herself. So, I thought the easiest way was to put an autonumber in the Company-personID table and have a table (alternates) that had two fields, "alternate" and "director", both using that autonumber to link them. However, it appears as though I can't link the same primary key twice to two foreign keys of the same table.

[URL]

View 3 Replies View Related

Forms :: Primary Key As Multiple Foreign Keys In Single Table

Mar 26, 2013

I'm developing a simple sporting records db. I have a 'Competitor' table listing competitors as follows: CompetitorPK, Name, Division, Club. I have a 'Contest' table listing contests as follows: ContestPK, Competitor1_FK, Competitor2_FK, Winner_FK, Score etc. My question is have I modelled tables correctly i.e. CompetitorPK will appear in three columns of Contest table. How do I define this relationship? What alternative is there to what I have done.I intend to use forms to populate both tables (independantly obviously).

View 4 Replies View Related

Tables :: Setting Primary Keys To More Than One Field In Table / But They Cannot Have Null Values

Nov 30, 2012

Access 2010..One organization that we work with provides us with a block of numbers for each of the two types of contract products we order from them; we do order non-contract stuff from them also.The block of numbers are the same (i.e. 20000 to 30000 this year) for each of the two products. This means that each product can have the number 20000, for example. We call this the Tracking Number. If it is one of these products, we need to select the Contract Number.

For all other one off orders we have with them, we assign our own Tracking Number starting with 00001. This Tracking Number cannot duplicate unless it is one of the aforementioned two products.Both the Tracking Number and Contract Number are in the same table. The user selects the Contract Number from a form (connected to the Contract Number table that has all the details on the contract) and the Contract Number is populated in the same table that has the Tracking Number.Each order must have a Tracking Number (no null)..Not all orders need a Contract Number (null okay).The Tracking Number and Contract Number combination cannot duplicate.I tried setting the primary keys to more than one field in the table, but they cannot have null values.

If not... I have been working on Plan B.... an AfterUpdate on the form (either the form or a field... don't know yet) that looks at a query that only has results if there are duplicate values.

View 1 Replies View Related

F Keys

Jul 12, 2006

Is it possible to use F keys to call Forms/Queries. I have used the code below and found when i press F7 spell ceck runs:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF7 Then

Dim stDocName As String

stDocName = "qryDepartment1"
DoCmd.OpenQuery stDocName, acNormal, acEdit

End If
End Sub

I have put this code in the keydown on the form.

Do i need to disable the existing F keys duties.

View 4 Replies View Related

Primary Keys

Nov 28, 2005

I was wondering if anyone would be able to help me? I have two tables which can be linked together as they both contain a field called Company Name. However, in one of the tables I want Company Name to become my primary key but this field contains duplicates. How can Isolve this so that I can still link my two tables together?

View 2 Replies View Related

Link Tbl Keys...which Way To Go?

May 13, 2006

Hi Forum,
I'm building a db to track computer and user problems for work, where I double as a Client Support Administrator (IT Guy).
I have these tables: (simplified list)

tblComputers
tblPeople
tblCompAssignment
tblProblems

I'm at a loss as to how to link the 'Problems' table. This is where I'll record trouble tickets reported by users.
Incoming trouble tickets could relate to the Computer or to the User's Network Login.
I thought I might have a field in the problems table for UserName and also one for ComputerID, but this seems problematic. Anyone got any ideas?

View 12 Replies View Related

Foreign Keys

Aug 25, 2006

Hi,

While designing a database, I came up with 3 different foreign keys in one table. I am afraid this is not right!

Is it possible to have this number of FK in one table or does that suggest a design flaw?

Any help will be very much appreciated.
B

View 7 Replies View Related

Help? Security & Hot Keys

Nov 27, 2007

I am trying to secure my database. I only want people to be able to view the forms that I have created, not the underlying tables, queries, etc. When I open the database, I have it set-up so the menu form opens and the database window with all the tables, queries, etc is not viewed. To view the database window, I use the F11 hotkey. In the start-up menu, I found where to turn these specials hotkeys off, but then as the administrator, if I open the database, how do I open the database window? Every time I open the database now, all I get is my form and I can't get the database window to open?!?

View 2 Replies View Related

Composite Keys

Dec 5, 2005

I have recently started a new project, on one of my tables i have a composite key for my primary key. However when i create a relationship using one of the fields in the primary key i can't "enforce referential integrity". Every time i try i get the message "No unique index found for the referenced field of the primary field"

can any one help

Mindy

View 2 Replies View Related

Primary Keys

Jun 26, 2007

I have two tables :

schema with :

schema-id, Autonumber, primary key
name, text

and a table regel :

regel-id, Autonumber
class a, number (lookup from a table)
class b, number (lookup from a table)
schema-id, Long number

they are linked 1:n. A schema can have many regel's.

I want to make a form of schema and have that form contain a subform with regel's in it. The subform can be shown as a datagrid.

Now here's what I do.. I start the form wizard and select both tables. The wizard takes me to creating what I want and it works too. I have a main form schema and a subform with regel's.

Now I have a problem :

The regel fields (class a and class b) can have only three possible values. And I don't want that the combination of these two fields can be the same.

I'v thought about making these two fields the primary keys of regel, but that doesn't work. It works for one record of schema, but when I navigate to a next record of schema, I can't make all combinations of class a and class b over again. It's like I used the combinations in the preceding record of scheme. Then I tried making three fields the primary key, namely class a and class b and regel-id. Didn't work either. What I need is a primary key on the combination of schema-id, class a and class b. But I don't know how to do that.. after all, schema and regel are seperate tables.

I want to be able to make for every schema record all possible combinations for regel records.

How do I do that?

View 7 Replies View Related

Many To Many And Composite Keys

Oct 6, 2007

Many to Many

I have a basic question, I know for a fact that all many to many relationships have to be broken into two one to many relationships using a junction table. However does that mean it is (a must )to have the two foreign key of the parent tables have to be the (primary composite key) of the junction table.

For example, let’s say I have 5 tables that I need to establish many to many relationships between them. Is it correct to establish a junction table with all 5 foreign keys of the parent tables as composite primary key in the junction table to!

Hope the above making sense!!! :confused:

Many thanks :)

View 3 Replies View Related

Query Using 2 Keys

Feb 28, 2008

I have a database that consists of 7 tables all linked by a school id number. The other tables hold data related to the schools. Another field common to all the related tables is a date field. I could use some direction on how to structure a query that selects data by school and a specific year. The related tables hold data for a number of years and I need to query and report by school for a given year. My main table holds generic school info. The other tables are linked by school_id and have a year field. I have a query that holds all the data - the trick is how to get the data filtered by year. Thanks for getting me started.

View 1 Replies View Related

Saving Keys

Jun 27, 2005

I have a form in which a user uses multiple combo boxes to choose certain items. each item in the combo box has a key attached to it in the table that the form was created from. I would like to save the appropriate key on my form next to the combo box. If this is possible, how do I go about doing this?

Thanks.

View 3 Replies View Related

Using Function Keys

Sep 1, 2004

How can I use function keys to get it to do a constant thing throughout all my forms etc. e.g. to nominate eg "F3" to save data or "F5" to go back a page etc.

View 2 Replies View Related

Composite Keys Possible?

May 13, 2005

Can Access deal with Composite Primary Keys? or will it only let you assign a single attribute key?

If it does allow you to create composite primary keys, how do you go about doing it?

View 1 Replies View Related

Disabled Keys

Dec 17, 2006

Hello,

I have created a log in form in my database and users will enter their name using a combo. Is there a way I can force them to use the mouse and select their name and not type in the data? Basically something that will disables all keys from the keyboard? Thanks.

View 3 Replies View Related

Changing Primary Keys

May 1, 2005

Hello all,

I am re-working an old database that 'grew up' the wrong way. It is a medical patient database and has 4 main tables. Primary key of main data table is Medical Record number (MR#), a user entered field (I know...). This links to 3 other tables: Diagnoses (indexed by MR# as well, 1-to-1 relationship with main table), Consults (indexed by a compound key of MR# and date, 1 to many relationship), and Procedures (indexed as well by MR# and date; 1 to many as well).

Here is my plan, and I want to know if I'm going to go about it the right way:

I will first delete the relationships between these tables.
I will then give the main table an autonumber field called PatientIndex, and each other table their own autonumber (DiagnosisIndex, ConsultIndex, ProcedureIndex). I will also give each of the other 'daughter' tables a PatientIndex field as well. I will populate the PatientIndex fields of the daughter records with a VBA routine that matches their MR# with the MR# in the main table, and then inserts the corresponding PatientIndex.

Now that each table has no relationships, and has all the right fields, I suspect Access will allow me to change the Keys for each table, and create new relationships, and it should all work cleanly. The goal is to have each table indexed by an autonumber field that is unrelated to user entry, and to link them by the Primary key.

Does this sound like the right approach? As to why do this if it works OK, it's a matter of maintenance. It's simply too buggy as it stands, and it's torturing me. Will my plan work without crashing the db?

View 5 Replies View Related

Xml Formatting And Handling Of Keys

Jun 29, 2006

When I export my access database to XML I noticed that the XML elements for the table keys contain the key numbers themselves, not the table name (or a chosen field in the table). For an application I am working on, this presents a problem. What I have is:

One table called 'Process' that looks like:

Process instance_idSystem instance IdProcess name
26 24 Two_thread_process


I have another table called "Thread":

Thread _instance_id Process instance_Id Thread instance name
30 26 T1_instance


XML export looks like:

- <process_INSTANCE>
<process_instance_id>26</process_instance_id>
<system_instance_name_id>24</system_instance_name_id>
<process_instance_name>two_thread_process</process_instance_name>
- <thread_INSTANCE>
<Thread_instance_id>30</Thread_instance_id>
<process_instance_id>26</process_instance_id>
<thread_instance_name>T1_instance</thread_instance_name>
</thread_INSTANCE>
</process_INSTANCE>

What I would *like * the XML to look like is:

- <process_INSTANCE>
<process_instance_id>26</process_instance_id>
<system_instance_name_id>24</system_instance_name_id>
<process_instance_name>two_thread_process</process_instance_name>
- <thread_INSTANCE>
<Thread_instance_id>30</Thread_instance_id>
<process_instance_id>two_thread_process</process_instance_id> (**name instead of key here**)
<thread_instance_name>T1_instance</thread_instance_name>
<thread_instance_type>periodic</thread_instance_type>
</thread_INSTANCE>

The access XML export writes out the key values as they appear in the tables. What I would like is for it to put in the ‘process instance name’ instead of the key that points back to the base (process) field.
Any pointers on how I could do this?

Thanks
John

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved