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 » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query Help Please



 
 
Thread Tools Display Modes
  #1  
Old February 11th, 2010, 03:06 PM posted to microsoft.public.access
Karin
external usenet poster
 
Posts: 272
Default Query Help Please

I have a relational db with a Client Table and a Project Table. The Client
table holds general info that usually doesn't change. The Project table has
a record for each project we've done for the client, and contains a Manager
field. The manager could change from year to year. I want to show by
current manager all the other projects for that client (regardless of who
previous manager was). Current manager is just the manager on the latest
project. I'm guessing I need a query of a query, but I'm stumped. Any
advice would be appreciated. Thanks.
  #2  
Old February 11th, 2010, 03:29 PM posted to microsoft.public.access
John Spencer
external usenet poster
 
Posts: 7,815
Default Query Help Please

Do you have a query that shows the latest project for the client and the
project manager for that project?

If so, please post the SQL of that query.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Karin wrote:
I have a relational db with a Client Table and a Project Table. The Client
table holds general info that usually doesn't change. The Project table has
a record for each project we've done for the client, and contains a Manager
field. The manager could change from year to year. I want to show by
current manager all the other projects for that client (regardless of who
previous manager was). Current manager is just the manager on the latest
project. I'm guessing I need a query of a query, but I'm stumped. Any
advice would be appreciated. Thanks.

  #3  
Old February 11th, 2010, 04:26 PM posted to microsoft.public.access
Karin
external usenet poster
 
Posts: 272
Default Query Help Please

This gets a list of all clients' latest projects
******
SELECT tblClients!IDClients & "-0" AS IDSched, tblClients.ClientName,
tblProjectType.ProjectType, tblProjects.Partner, tblProjects.Manager,
tblProjects.ProjectFYE
FROM tblProjectType RIGHT JOIN (tblClients LEFT JOIN tblProjects ON
tblClients.IDClients = tblProjects.IDClients) ON tblProjectType.RowIDProjType
= tblProjects.ProjectTypeID
WHERE (((tblProjects.ProjectFYE)#1/1/2007#) AND
((tblProjects.CreateNewProject)=0) AND ((tblProjects.SignatureDate) Is Not
Null) AND ((tblProjects.ArchivedDate) Is Null) AND
((tblClients.InactiveClient)=False) AND ((tblProjects.Billed)2)) OR
(((tblProjects.ProjectFYE)#1/1/2007#) AND ((tblProjects.CreateNewProject)=0)
AND ((tblProjects.SignatureDate) Is Null) AND ((tblProjects.ArchivedDate) Is
Null) AND ((tblClients.InactiveClient)=False) AND ((tblProjects.Billed)2))
OR (((tblProjects.ProjectFYE)#1/1/2007#) AND
((tblProjects.CreateNewProject)0) AND ((tblProjects.SignatureDate) Is Not
Null) AND ((tblProjects.ArchivedDate) Is Null) AND
((tblClients.InactiveClient)=False) AND ((tblProjects.Billed)2))
ORDER BY tblClients.ClientName, tblProjects.Partner, tblProjects.Manager,
tblProjects.ProjectFYE;


******


"John Spencer" wrote:

Do you have a query that shows the latest project for the client and the
project manager for that project?

If so, please post the SQL of that query.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Karin wrote:
I have a relational db with a Client Table and a Project Table. The Client
table holds general info that usually doesn't change. The Project table has
a record for each project we've done for the client, and contains a Manager
field. The manager could change from year to year. I want to show by
current manager all the other projects for that client (regardless of who
previous manager was). Current manager is just the manager on the latest
project. I'm guessing I need a query of a query, but I'm stumped. Any
advice would be appreciated. Thanks.

.

  #4  
Old February 11th, 2010, 04:45 PM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Query Help Please

On Thu, 11 Feb 2010 07:06:02 -0800, Karin
wrote:

I have a relational db with a Client Table and a Project Table. The Client
table holds general info that usually doesn't change. The Project table has
a record for each project we've done for the client, and contains a Manager
field. The manager could change from year to year. I want to show by
current manager all the other projects for that client (regardless of who
previous manager was). Current manager is just the manager on the latest
project. I'm guessing I need a query of a query, but I'm stumped. Any
advice would be appreciated. Thanks.


Try a subquery, something like

SELECT Clients.thisfield, Clients.thatfield, Projects.thisfield,
Projects.thatfield
FROM Clients INNER JOIN Projects ON ClientID = Projects.ProjectID
WHERE Clients.ClientID IN(SELECT ClientID FROM Projects WHERE Projects.Manager
= whatever)
--

John W. Vinson [MVP]
  #5  
Old February 11th, 2010, 04:46 PM posted to microsoft.public.access
Karin
external usenet poster
 
Posts: 272
Default Query Help Please

I have figured out how to run a query on one manager and then with a 2nd
query, link that with a join to all other projects for those clients, which
will work, but I haven't figured out how to do it for multiple managers so I
can run a report by manager.

"Karin" wrote:

This gets a list of all clients' latest projects
******
SELECT tblClients!IDClients & "-0" AS IDSched, tblClients.ClientName,
tblProjectType.ProjectType, tblProjects.Partner, tblProjects.Manager,
tblProjects.ProjectFYE
FROM tblProjectType RIGHT JOIN (tblClients LEFT JOIN tblProjects ON
tblClients.IDClients = tblProjects.IDClients) ON tblProjectType.RowIDProjType
= tblProjects.ProjectTypeID
WHERE (((tblProjects.ProjectFYE)#1/1/2007#) AND
((tblProjects.CreateNewProject)=0) AND ((tblProjects.SignatureDate) Is Not
Null) AND ((tblProjects.ArchivedDate) Is Null) AND
((tblClients.InactiveClient)=False) AND ((tblProjects.Billed)2)) OR
(((tblProjects.ProjectFYE)#1/1/2007#) AND ((tblProjects.CreateNewProject)=0)
AND ((tblProjects.SignatureDate) Is Null) AND ((tblProjects.ArchivedDate) Is
Null) AND ((tblClients.InactiveClient)=False) AND ((tblProjects.Billed)2))
OR (((tblProjects.ProjectFYE)#1/1/2007#) AND
((tblProjects.CreateNewProject)0) AND ((tblProjects.SignatureDate) Is Not
Null) AND ((tblProjects.ArchivedDate) Is Null) AND
((tblClients.InactiveClient)=False) AND ((tblProjects.Billed)2))
ORDER BY tblClients.ClientName, tblProjects.Partner, tblProjects.Manager,
tblProjects.ProjectFYE;


******


"John Spencer" wrote:

Do you have a query that shows the latest project for the client and the
project manager for that project?

If so, please post the SQL of that query.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Karin wrote:
I have a relational db with a Client Table and a Project Table. The Client
table holds general info that usually doesn't change. The Project table has
a record for each project we've done for the client, and contains a Manager
field. The manager could change from year to year. I want to show by
current manager all the other projects for that client (regardless of who
previous manager was). Current manager is just the manager on the latest
project. I'm guessing I need a query of a query, but I'm stumped. Any
advice would be appreciated. Thanks.

.

 




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 08:04 AM.


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