A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Lookup field in same table?



 
 
Thread Tools Display Modes
  #1  
Old May 14th, 2004, 09:17 PM
eagletender
external usenet poster
 
Posts: n/a
Default Lookup field in same table?

Can you create a field that will look up the id of a record in the same
table? For instance, a table of employees, with the SupervisorID as a field
so that it would reflect the id of the supervisor, but the supervisor is
also an employee. Or should I create 2 separate tables that would simply
link the 2 ids.


  #2  
Old May 15th, 2004, 12:31 AM
BigManT
external usenet poster
 
Posts: n/a
Default Lookup field in same table?


Eagle, no you cannot create a field that will lookup the id of a record in the same table, but you can accomplish this in a query which looks at the table. Use the DLoopup function. See Access help for how to set it up. Most people would probably have one table with a supervisor id field and then add that table twice to the same query and do a self join between the employee id field and the supervisor id field in order to see who is whose supervisor. For the man at the top, I suppose you could put his own employee id in his supervisor id field to show that he manages himself.

----- eagletender wrote: -----

Can you create a field that will look up the id of a record in the same
table? For instance, a table of employees, with the SupervisorID as a field
so that it would reflect the id of the supervisor, but the supervisor is
also an employee. Or should I create 2 separate tables that would simply
link the 2 ids.



  #3  
Old May 15th, 2004, 08:21 AM
John Vinson
external usenet poster
 
Posts: n/a
Default Lookup field in same table?

On Fri, 14 May 2004 14:17:22 -0600, "eagletender"
wrote:

Can you create a field that will look up the id of a record in the same
table? For instance, a table of employees, with the SupervisorID as a field
so that it would reflect the id of the supervisor, but the supervisor is
also an employee. Or should I create 2 separate tables that would simply
link the 2 ids.


You can create a "self join query" - but I would STRONGLY recommend
that you not use a "self join lookup" in a table, or for that matter
ANY Lookup Field in ANY table. See
http://www.mvps.org/access/lookupfields.htm for a critique of this
misfeature!

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:15 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.