Important alert: (current site time 7/15/2013 10:35:07 PM EDT)
 

article

Access Databse - Create Relationship's Between 2 Tables

Email
Submitted on: 9/25/2004 3:27:44 PM
By: Wayne Barron aka: Carrzkiss  
Level: Beginner
User Rating: By 6 Users
Compatibility: ASP (Active Server Pages)
Views: 18636
author picture
(About the author)
 
     wanting to make a Complex ASP Site? But you are unable to make the connection between "2 or more Tables" ? This Tutorial will show you how to make a [ Access Database Table Relationship ]


 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				I have always wanted to know how to create Relationships between "2 Tables" 
in a Database.
As I would like to build/Design a web site like Planet? (But not as a Competitor) But dedicated
To one type of Programming Language : Delphi.
I was informed that if I do decide to design a site like this, then I would have to make
Access Database - Table-Relationships. OK, but could not find any information on how
to do it. Then I came across it last night: September 24, 2004. And man oh man, I was a very
Happy person :-)

OK. Lets get on with the lesson on Creating Table Relationships in Access.

Lets start out by opening up "Access" (I am using Access 2000, Hopefully it will be
The same in all versions, if not, please read up on " Relationships " in the Access Help)

Lets create a new Database. Lets give it the name of: [Relations]


Now lets click on [Design View]
In [Design View]. Type in the following

FieldName......................DataType
========================
ID....................................AutoNumber
(Make ID the [Primary Key])
UserID..............................text
UserPass...........................text

Choose to [Save] with name: [ Users ]

Next lets create another Table. By clicking on
[Design View] again. And typing in this

FieldName......................DataType
========================
ID...................................AutoNumber
(Make ID the [Primary Key])
FName.............................text
LName.............................text
UEmail..............................text
UAddress..........................text
UPhone.............................text
UZip...............................text
UState...............................text

[Save] this Table with name: [UInfo]

===========================
Now that we have are "2" Tables
Table: Users
Table: UInfo

Created, it is time to create the [Database Table Relationships] Between them.
So are you ready to learn something that know one will show/tell you how to do?
Alrighty then, lets Rock and Roll the Database, into High Gear.

==============

In the Database [Relationships] you see your 2-Tables.
[Right Click] Anywhere in the "White Area" Around the Tables
(But not on the Tables) And choose: "Relationships...."

When the [Relationships] Dialog Box, appears, it will show you all the Tables.
That is in our Database. Choose [Users] & [UInfo] from the list.
And choose [Add]
They will appear behind the "Show Tables" Dialog, So lets close the " Show Tables" Dialog.
And now you see both Tables. [Users] & [UInfo].

--------------------

In this next step, we have to decide which area that we want to create the Relationship for?
So we are going to create the Relations between the " 2 - ID " Fields, since these are
[ AutoNumber ] fields, and they will stay consistent with one another, as new records
Are recorded into it. So lets Create the Relationship, between them.

[Left Click] on the
"Users = ID"
And "Drag & Drop" over to and on top of
"UInfo = ID" Field

This will then Popup a Dialog [Edit Relationships]
Leave it Default [ID | ID] and choose [Create]
This will create a line between
Users=ID --------- UInfo=ID
That lines means that these 2 Fields in the Table are connected together.

You can now close out of the [Relationships] Dialog, and get Back to your
Database View.

Now click on the Table: UInfo. And put some information in the Fields.
[Save] The information, then click on the Table: Users. And Add a User.
(Making sure that the User matches the Name that you create in UInfo.
So they will be the same. For each Record that is created in the Tables.
They are assigned a Unique Number for their ID. This is the AutoNumber.
So the Relationship between the "2" tables is connected by the "AutoNumber"
Of the [ID]. So if the Record you create in [UInfo] has ID# 1
Then in [Users] The new User has ID#1. Is the Same User?
So for every record that is created, make sure they there Unique ID# is the same. )

After you have created a "New Record" in each Table, Open up each Table.
And you should see a: [+] beside each entry.
Click on the [+] and it should show you the Relationship that corresponds with
That Entry.
If you receive an error: Then close out of the Table, and go back into the
Relationships.... and make sure that you Create the Relationship
Between both [ID] and nothing else.
And then make sure that the [ID] in each table, is a " AutoNumber "

And that should take care of it.
This will be posted to our "Knowledge Base" as well.
Which at the moment is secure, with no outside access.
Please check on ' www.carrz-fox-fire.com " in the near future, for a new look
to the Internet.

Thank you and hope that this Article is helpful in your pursuit in making that
Killer ASP page.

Wayne & Carr Barron
Carrz-Fox-Fire Promotions


Other 3 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

9/29/2004 7:09:32 AM

great article for the beginner. Good job.
(If this comment was disrespectful, please report it.)

 
10/6/2004 9:44:55 PMWayne & Carr Barron

Thank you for your comment.
Please do not forget to Vote.
A lot of work goes into these submissions. So people please Vote if you find this helpful.

Thank You
Wayne & Carr Barron
Carrz-Fox-Fire Promotions
(If this comment was disrespectful, please report it.)

 
4/22/2005 3:42:02 AM

how about by using sql server?
(If this comment was disrespectful, please report it.)

 
4/22/2005 9:45:06 AMWayne & Carr Barron

I am sorry,
I do not know anything about SQL Server.
So I am of no help there.

This might help you out though

http://www.google.com/search?hl=en&q=SQL+Create+Table+Relationships
(If this comment was disrespectful, please report it.)

 
9/11/2005 1:36:07 AMmarya,

Thanks.that realy great for beginner,i am new to access and it was realy useful for me
(If this comment was disrespectful, please report it.)

 
9/11/2005 11:32:52 AMWayne & Carr Barron

It is nice to know that people are still able to learn by this example.
5,023 visitors total have viewed this article, though only 1-person has voted.
Better "1" then no one right?

Good luck to everyone that learns from
This information.

Wayne & Carr Barron
ŪCarrz-Fox-Fire Promotions
(If this comment was disrespectful, please report it.)

 
11/20/2005 11:58:27 AMAndrew Benedicts L

Mana code yang bisa di download na?
(If this comment was disrespectful, please report it.)

 
9/14/2006 9:23:02 AMausoni

it is excellent man. Good job
(If this comment was disrespectful, please report it.)

 
2/19/2007 6:45:12 AMBasabendra

Good job
(If this comment was disrespectful, please report it.)

 
3/28/2008 4:26:39 AMcyrus rynlee

ok.i know how to perform this feat. but what i want it done programmatically, not manually. can you provide a source or link for a vb code that does the same thing as the one you've been talking about here? Thanks.
(If this comment was disrespectful, please report it.)

 
4/1/2008 11:48:20 PMHung

devlope
(If this comment was disrespectful, please report it.)

 
4/1/2008 11:54:16 PMHung

good
(If this comment was disrespectful, please report it.)

 
4/29/2009 2:04:33 AMCML

Excellent article. I wish I had seen this years ago when I was learing Access. Keep up the good work.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.