PC Review


Reply
Thread Tools Rate Thread

cross referencing records from same table

 
 
=?Utf-8?B?cmp3MjQ=?=
Guest
Posts: n/a
 
      16th Jul 2007
Is there anyway I can link records that are in the same table. For example, I
have a datbase that is used for recording events. Events that are similar are
sometimes linked together and I wondered if there was a way I could have a
field that links to another record from the same table.

Thanks
 
Reply With Quote
 
 
 
 
=?Utf-8?B?c2N1YmFkaXZlcg==?=
Guest
Posts: n/a
 
      16th Jul 2007

I have a suggestion that may help. I designed a db for a photographer and
some of clients may know other clients so I built a one-to-many relationship
between one client and others. The many side uses the same table as the
source of a query. I filter the query so that it to excludes the client that
is currently chosen (if you understand!). That way you can link many records
from the same table.

I hope that helps.




"rjw24" wrote:

> Is there anyway I can link records that are in the same table. For example, I
> have a datbase that is used for recording events. Events that are similar are
> sometimes linked together and I wondered if there was a way I could have a
> field that links to another record from the same table.
>
> Thanks

 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      16th Jul 2007
I'm not completely clear about what you are doing, but it is possible for
one record to refer to another in the same table.

For example, if and event (like a sales fair) arises as the result of
another fair, and you want to track which event gave rise to which other
events, you would add a field to the table like this:
ParentEventID Number

Assuming you already have an EventID (AutoNumber, primary key), you would
then create the relationship like this:

1. Open the Relationship Window (Tools menu.)

2. Add the Events table to the window a 2nd time.
Access will alias the 2nd copy as Events_1.

3. Drag Events.EventID and drop onto Events_1.ParentEventID.
Check the box for Relational Integrity, and create the relation.

In a similar way, you can use 2 copies of the table in a query. In query
design, you can set the Alias property of the table to whatever you want.

This kind of thing is called a self-join. It is quite common for anything
where you trace generations or subassemblies.

Another example:
Self Joins: tables that look themselves up (Pedigrees example)
at:
http://allenbrowne.com/ser-06.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"rjw24" <(E-Mail Removed)> wrote in message
news:408441D4-8EAF-4F7C-850C-(E-Mail Removed)...
> Is there anyway I can link records that are in the same table. For
> example, I
> have a datbase that is used for recording events. Events that are similar
> are
> sometimes linked together and I wondered if there was a way I could have a
> field that links to another record from the same table.
>
> Thanks


 
Reply With Quote
 
=?Utf-8?B?cmp3MjQ=?=
Guest
Posts: n/a
 
      16th Jul 2007
Excellent,

Thank you,

Now on to my next question...is there anyway that once I have selected the
record that is linked that it automatically updates the respective record. So
for example:

Event 1 is linked to Event 2 and I specify this by inserting it in to field
named 'Link' on the Event 1 record. Could I make the 'Link' field on Event 2
automatically link back to Event 1.

Heres the chain of what I would like to happen:

In the record, Event 1, I insert Event 2 (from a dropdown box, I have
already made).

After this field had been updated I would like Event 1 to be inserted in to
the 'Link' field on Event 2.

I hope this clear

Thanks

"Allen Browne" wrote:

> I'm not completely clear about what you are doing, but it is possible for
> one record to refer to another in the same table.
>
> For example, if and event (like a sales fair) arises as the result of
> another fair, and you want to track which event gave rise to which other
> events, you would add a field to the table like this:
> ParentEventID Number
>
> Assuming you already have an EventID (AutoNumber, primary key), you would
> then create the relationship like this:
>
> 1. Open the Relationship Window (Tools menu.)
>
> 2. Add the Events table to the window a 2nd time.
> Access will alias the 2nd copy as Events_1.
>
> 3. Drag Events.EventID and drop onto Events_1.ParentEventID.
> Check the box for Relational Integrity, and create the relation.
>
> In a similar way, you can use 2 copies of the table in a query. In query
> design, you can set the Alias property of the table to whatever you want.
>
> This kind of thing is called a self-join. It is quite common for anything
> where you trace generations or subassemblies.
>
> Another example:
> Self Joins: tables that look themselves up (Pedigrees example)
> at:
> http://allenbrowne.com/ser-06.html
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "rjw24" <(E-Mail Removed)> wrote in message
> news:408441D4-8EAF-4F7C-850C-(E-Mail Removed)...
> > Is there anyway I can link records that are in the same table. For
> > example, I
> > have a datbase that is used for recording events. Events that are similar
> > are
> > sometimes linked together and I wondered if there was a way I could have a
> > field that links to another record from the same table.
> >
> > Thanks

>
>

 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      17th Jul 2007
I think that requires some thought about the nature of the link between the
2 fields.

For the example I suggested, one sales fair can give rise to several other
fairs. There is therefore a one-to-many relation. This kind of relation
could not be stored as a single reciprocal relationship like you describe.

If the relation is many-to-many you could model that with a junction table
between 2 copies of the table (if there were always exactly 2 events involvd
in the relation.)

Or, you could specify the group, and have many events grouped together. For
an example of that structure, see tblGroupClient in the screenshot on this
page:
http://allenbrowne.com/AppHuman.html
That's the core table representing a
family/committee/company/some-collection-of-people who belong to a group.
This structure would certainly be the most flexible, and probably the most
applicable tof a reciprocal relation.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"rjw24" <(E-Mail Removed)> wrote in message
news:676E17FE-4767-47BA-BEA9-(E-Mail Removed)...
> Excellent,
>
> Thank you,
>
> Now on to my next question...is there anyway that once I have selected the
> record that is linked that it automatically updates the respective record.
> So
> for example:
>
> Event 1 is linked to Event 2 and I specify this by inserting it in to
> field
> named 'Link' on the Event 1 record. Could I make the 'Link' field on Event
> 2
> automatically link back to Event 1.
>
> Heres the chain of what I would like to happen:
>
> In the record, Event 1, I insert Event 2 (from a dropdown box, I have
> already made).
>
> After this field had been updated I would like Event 1 to be inserted in
> to
> the 'Link' field on Event 2.
>
> I hope this clear
>
> Thanks
>
> "Allen Browne" wrote:
>
>> I'm not completely clear about what you are doing, but it is possible for
>> one record to refer to another in the same table.
>>
>> For example, if and event (like a sales fair) arises as the result of
>> another fair, and you want to track which event gave rise to which other
>> events, you would add a field to the table like this:
>> ParentEventID Number
>>
>> Assuming you already have an EventID (AutoNumber, primary key), you would
>> then create the relationship like this:
>>
>> 1. Open the Relationship Window (Tools menu.)
>>
>> 2. Add the Events table to the window a 2nd time.
>> Access will alias the 2nd copy as Events_1.
>>
>> 3. Drag Events.EventID and drop onto Events_1.ParentEventID.
>> Check the box for Relational Integrity, and create the relation.
>>
>> In a similar way, you can use 2 copies of the table in a query. In query
>> design, you can set the Alias property of the table to whatever you want.
>>
>> This kind of thing is called a self-join. It is quite common for anything
>> where you trace generations or subassemblies.
>>
>> Another example:
>> Self Joins: tables that look themselves up (Pedigrees example)
>> at:
>> http://allenbrowne.com/ser-06.html
>>
>> "rjw24" <(E-Mail Removed)> wrote in message
>> news:408441D4-8EAF-4F7C-850C-(E-Mail Removed)...
>> > Is there anyway I can link records that are in the same table. For
>> > example, I
>> > have a datbase that is used for recording events. Events that are
>> > similar
>> > are
>> > sometimes linked together and I wondered if there was a way I could
>> > have a
>> > field that links to another record from the same table.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross Referencing data in the same table Bill Walsh Microsoft Access 4 17th Feb 2009 12:58 PM
RE: Cross-Referencing Correspondence Records KARL DEWEY Microsoft Access Database Table Design 0 21st May 2008 12:35 AM
cross-table referencing question =?Utf-8?B?am1hbg==?= Microsoft Access Database Table Design 0 20th Jun 2006 04:07 PM
cross referencing bookmark from one table to another =?Utf-8?B?QW15IFdhbmc=?= Microsoft Word Document Management 2 22nd Oct 2005 04:28 AM
Automcatically Cross-Referencing Records Tom Microsoft Access Form Coding 0 27th Jun 2005 09:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:03 PM.