Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Data from two or more fields in a table 1

Status
Not open for further replies.

Bill4tektips

Technical User
Aug 5, 2005
175
GB
I have a tabe containing LogInID, TeamLeader(Yes/NO), TeamID1 and TeamID2. I need a query to check if the person logged on (LogInID) is a Team Leader and if they are list all the people who are in their Team (TeamID1 and TeamID2). Some people can belong to more than 1 Team hence the TeamID1 and 2. The TeamID1 and 2 fields contain a number.
Can anyone help?
 
I created a query team_001 to pull the Curerent User in to the Auditors table then created a query
"TeamID: IIf([team1_001]![TeamID1] Or [team1_001]![TeamID2]=[tblAuditor]![TeamID1],[tblAuditor]![TeamID1],0).
This works OK for TeamID1 but does not add TeamID2.
 
You wanted a list, so why not a listbox with a little SQL? For example:

Code:
SELECT TeamID From (SELECT tblAuditor.LogInID, tblAuditor.TeamLeader, tblAuditor.TeamID1 As TeamID
FROM tblAuditor
UNION
SELECT tblAuditor.LogInID, tblAuditor.TeamLeader, tblAuditor.TeamID2 As TeamID
FROM tblAuditor) A
WHERE TeamID=DlookUp("TeamID1","tblAuditor","LogInId='" & [CurrentUser] & "' And TeamLeader=True")
OR TeamID=DlookUp("TeamID2","tblAuditor","LogInId='" & [CurrentUser] & "' And TeamLeader=True")


PS It is very rarely a good idea to have a table that requires fields labeled x1, x2 etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top