** Edit ** Split from Rows & Columns
...
Now for a more challenging one...
What I have is a table for all of the contacts with clients. I run reports weekly and monthly. For this report I have the client ID in the contact table which looks to a query where I have clientid and lastnamefirstname. The report, of course, only shows names for those who have contacts for the duration of the report. What boss wants to see is the clients who are not having any contact for that period of time also. I have tried the unmatched query wizard which only gives me the clientids for clients who have never had any contacts. Is there a way for me to get all of the client names into the report, or even run a different report that gives the clientids of the no contact clients for a certain period? Let me know if you need more info, I will do my best
6 2118 NeoPa 32,556
Expert Mod 16PB
I am not sure what I am tring to do myself half the time :)
So I took your advice and tried subreports...did the trick...the boss likes the way it turned out. Now for a more challenging one...
What I have is a table for all of the contacts with clients. I run reports weekly and monthly. For this report I have the client ID in the contact table which looks to a query where I have clientid and lastnamefirstname. The report, of course, only shows names for those who have contacts for the duration of the report. What boss wants to see is the clients who are not having any contact for that period of time also. I have tried the unmatched query wizard which only gives me the clientids for clients who have never had any contacts. Is there a way for me to get all of the client names into the report, or even run a different report that gives the clientids of the no contact clients for a certain period? Let me know if you need more info, I will do my best
There is - and I do need more info.
I need the table meta-data as well as names and SQL of any queries you will need involved. Here is an example of how to post table MetaData : Table Name=tblStudent - Field; Type; IndexInfo
-
StudentID; AutoNumber; PK
-
Family; String; FK
-
Name; String
-
University; String; FK
-
Mark; Numeric
-
LastAttendance; Date/Time
Please use the coding I've used (It can be copied in the edit box of a reply to this post).
We may need to use subqueries here, but I'll know better when I have all the information.
OK, Here we go
Client Contact table info -
tblClientContactWithFunding
-
ID; Number
-
ClientID; Number
-
Staff ;Text
-
Date; Date/Time
-
Department; Text
-
Duration; Number
-
Phase; Text
-
Method; Text
-
Support; Text
-
Comments; Memo
-
FundingID; Number
-
FundingClientID; Number
-
Funding; Text
-
Current; Text
-
Query for LastNameFirstName -
qryClientName
-
SELECT Trim([LastName] & ", " & [FirstName]) AS ClientName, tblClient.ID, tblClient.EmploymentConsultant
-
FROM tblClient
-
ORDER BY Trim([LastName] & ", " & [FirstName]);
-
Table for Funding -
tblFundingCost
-
Funding; Text
-
Amount; Currency
-
Here is the query that I use for the report -
qryClientDetail
-
SELECT tblClientContactWithFunding.ID, tblClientContactWithFunding.ClientID, tblClientContactWithFunding.Department, tblClientContactWithFunding.Phase, tblClientContactWithFunding.Duration, tblClientContactWithFunding.Method, tblClientContactWithFunding.Support, tblClientContactWithFunding.Comments, tblClientContactWithFunding.FundingID, tblClientContactWithFunding.FundingClientID, tblClientContactWithFunding.Current, qryClientName.ID, tblClient.CaseWorker, tblFundingCost.Amount, tblClientContactWithFunding.Staff, tblClientContactWithFunding.Funding, qryClientName.ClientName, tblClientContactWithFunding.Date, [Duration]*[Amount] AS Expr1
-
FROM (tblClient INNER JOIN (tblClientContactWithFunding INNER JOIN qryClientName ON tblClientContactWithFunding.ClientID = qryClientName.ID) ON tblClient.ID = tblClientContactWithFunding.ClientID) INNER JOIN tblFundingCost ON tblClientContactWithFunding.Funding = tblFundingCost.Funding
-
WHERE (((tblClientContactWithFunding.Funding)=[Forms]![frmClientContactRptInfo]![Combo5]) AND ((qryClientName.ClientName)=[Forms]![frmClientContactRptInfo]![Combo1]) AND ((tblClientContactWithFunding.Date)>=[Forms]![frmClientContactRptInfo]![Text7] And (tblClientContactWithFunding.Date)<=[Forms]![frmClientContactRptInfo]![Text11])) OR ((([Forms]![frmClientContactRptInfo]![Combo5]) Is Null) AND (([Forms]![frmClientContactRptInfo]![Combo1]) Is Null) AND ((([tblClientContactWithFunding].[Date])>=[Forms]![frmClientContactRptInfo]![Text7]) Is Null) AND ((([tblClientContactWithFunding].[Date])<=[Forms]![frmClientContactRptInfo]![Text11]) Is Null)) OR (((qryClientName.ClientName)=[Forms]![frmClientContactRptInfo]![Combo1]) AND (([Forms]![frmClientContactRptInfo]![Combo5]) Is Null) AND ((([tblClientContactWithFunding].[Date])>=[Forms]![frmClientContactRptInfo]![Text7]) Is Null) AND ((([tblClientContactWithFunding].[Date])<=[Forms]![frmClientContactRptInfo]![Text11]) Is Null)) OR (((tblClientContactWithFunding.Funding)=[Forms]![frmClientContactRptInfo]![Combo5]) AND (([Forms]![frmClientContactRptInfo]![Combo1]) Is Null) AND ((([tblClientContactWithFunding].[Date])>=[Forms]![frmClientContactRptInfo]![Text7]) Is Null) AND ((([tblClientContactWithFunding].[Date])<=[Forms]![frmClientContactRptInfo]![Text11]) Is Null)) OR (((tblClientContactWithFunding.Date)>=[Forms]![frmClientContactRptInfo]![Text7] And (tblClientContactWithFunding.Date)<=[Forms]![frmClientContactRptInfo]![Text11]) AND (([Forms]![frmClientContactRptInfo]![Combo5]) Is Null) AND (([Forms]![frmClientContactRptInfo]![Combo1]) Is Null)) OR (((tblClientContactWithFunding.Funding)=[Forms]![frmClientContactRptInfo]![Combo5]) AND ((tblClientContactWithFunding.Date)>=[Forms]![frmClientContactRptInfo]![Text7] And (tblClientContactWithFunding.Date)<=[Forms]![frmClientContactRptInfo]![Text11]) AND (([Forms]![frmClientContactRptInfo]![Combo1]) Is Null)) OR (((qryClientName.ClientName)=[Forms]![frmClientContactRptInfo]![Combo1]) AND ((tblClientContactWithFunding.Date)>=[Forms]![frmClientContactRptInfo]![Text7] And (tblClientContactWithFunding.Date)<=[Forms]![frmClientContactRptInfo]![Text11]) AND (([Forms]![frmClientContactRptInfo]![Combo5]) Is Null)) OR (((tblClientContactWithFunding.Funding)=[Forms]![frmClientContactRptInfo]![Combo5]) AND ((qryClientName.ClientName)=[Forms]![frmClientContactRptInfo]![Combo1]) AND ((([tblClientContactWithFunding].[Date])>=[Forms]![frmClientContactRptInfo]![Text7]) Is Null) AND ((([tblClientContactWithFunding].[Date])<=[Forms]![frmClientContactRptInfo]![Text11]) Is Null))
-
ORDER BY qryClientName.ClientName;
-
Since I run multiple reports at the same time I have a form where we input the dates Staff Names and Funding.
I hope this is all you need, let me know if I missed something.
NeoPa 32,556
Expert Mod 16PB
For the moment I'm just subscribing properly to the thread.
I hope to look at it in more depth over the weekend.
NeoPa 32,556
Expert Mod 16PB
This looks as if it might be really complicated, but then again it may be deceptively simple. I can't really go through the SQL for the query as there's just too much there (especially in Access mode SQL - non-tidied version). When it gets that involved it's easier to see in the design view, and even then it can get very hard to follow unless you understand what it's about already.
However, if I understand you aright, you have basically some clients and some contacts. The clients link to the contacts via a client ID (of whatever form).
Currently, you have a LEFT JOIN from the contacts to the clients (All contacts - only matching clients) and you want to show ALL clients, regardless of which have any contacts, but include the contact info for those with any. If that's so then you simply build the query with a LEFT JOIN from the Clients to the Contacts instead of the current version which is basically vice-versa.
Does that help (even make sense)?
I went through the sql on the query and see that all I have is inner join. Do I need to change one of these to left join? Here is a smaller version of the query I am working with -
SELECT tblClientContactWithFunding.ID, tblClientContactWithFunding.ClientID, tblClientContactWithFunding.Department, tblClientContactWithFunding.Phase, tblClientContactWithFunding.Duration, tblClientContactWithFunding.Method, tblClientContactWithFunding.Support, tblClientContactWithFunding.Comments, tblClientContactWithFunding.FundingID, tblClientContactWithFunding.FundingClientID, tblClientContactWithFunding.Current, qryClientName.ID, tblClient.CaseWorker, tblFundingCost.Amount, tblClientContactWithFunding.Staff, tblClientContactWithFunding.Funding, qryClientName.ClientName, tblClientContactWithFunding.Date, [Duration]*[Amount] AS Expr1
-
FROM tblClient INNER JOIN ((tblClientContactWithFunding INNER JOIN qryClientName ON tblClientContactWithFunding.ClientID = qryClientName.ID) INNER JOIN tblFundingCost ON tblClientContactWithFunding.Funding = tblFundingCost.Funding) ON tblClient.ID = tblClientContactWithFunding.ClientID
-
WHERE (((tblClientContactWithFunding.Date)>=#2/1/2008#))
-
ORDER BY qryClientName.ClientName;
-
-
NeoPa 32,556
Expert Mod 16PB
This is still quite involved, and the more involved it is, the more important that the SQL is displayed in a structured manner. I've reformatted the SQL you posted in such a way that it will work in exactly the same way, but tabulated it in such a way that it is much easier to read and understand. - SELECT tCCWF.ID,
-
tCCWF.ClientID,
-
tCCWF.Department,
-
tCCWF.Phase,
-
tCCWF.Duration,
-
tCCWF.Method,
-
tCCWF.Support,
-
tCCWF.Comments,
-
tCCWF.FundingID,
-
tCCWF.FundingClientID,
-
tCCWF.Current,
-
qCN.ID,
-
tC.CaseWorker,
-
tFC.Amount,
-
tCCWF.Staff,
-
tCCWF.Funding,
-
qCN.ClientName,
-
tCCWF.Date,
-
tCCWF.Duration*tFC.Amount AS Expr1
-
FROM tblClient AS tC INNER JOIN
-
((tblClientContactWithFunding AS tCCWF INNER JOIN
-
qryClientName AS qCN
-
ON tCCWF.ClientID = qCN.ID) INNER JOIN
-
tblFundingCost AS tFC
-
ON tCCWF.Funding = tFC.Funding)
-
ON tC.ID = tCCWF.ClientID
-
WHERE (((tCCWF.Date)>=#2/1/2008#))
-
ORDER BY qCN.ClientName
One can now see quite easily (nothing's ever really easy when working with SQL except "SELECT * FROM [Table]") that all the JOINs are INNER JOINs.
Assuming that my assertion in post #5 is correct :
Currently, you have a LEFT JOIN from the contacts to the clients (All contacts - only matching clients) and you want to show ALL clients, regardless of which have any contacts, but include the contact info for those with any. If that's so then you simply build the query with a LEFT JOIN from the Clients to the Contacts instead of the current version which is basically vice-versa.
...then this still needs a bit of fiddling with.
We have Record Sources in the FROM clause :
tblClient (Alias= tC)
qryClientName (Alias= qCN)
tblClientContactWithFunding (Alias= tCCWF)
tblFundingCost (Alias= tFC)
My guess would be that tblClient is client-side and tblClientContactWithFunding is contact side. The others are less obvious. qryClientName is probably client-side too, and tblFundingCost appears to be contact-side.
On the assumption above, I will set out your FROM clause (from FROM until just before WHERE) for you. - ...
-
FROM ((tblClient AS tC INNER JOIN
-
qryClientName AS qCN
-
ON tC.ID = qCN.ID) LEFT JOIN
-
tblClientContactWithFunding AS tCCWF
-
ON tC.ID = tCCWF.ClientID) LEFT JOIN
-
tblFundingCost AS tFC
-
ON tCCWF.Funding = tFC.Funding
-
WHERE ...
Ideally we would want to group the two client-side tables together with an INNER JOIN as well as (separately) the two contact-side tables and then join the two groupings together with a LEFT JOIN. Unfortunately Access can't handle INNER JOINs to the logical right of a LEFT JOIN.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: sal cifone |
last post by:
Hello,
I am trying to use access vba instead of running an unmatched query.
I want to compare two tables and if there is a new sales office in
"Commissions" table that is not in the "Conversion"...
|
by: Colleyville Alan |
last post by:
I want to extract some records that are common to three tables, but not
contained in the fourth. Following what I have see in the archives and also
trying the unmatched records query wizard, if I...
|
by: Ellen Ricca |
last post by:
I have an Access db with several ODBC linked ORACLE tables. These
tables have multiple-field PK's. The tables work just fine in many
diff types of queries including unmatched queries that are...
|
by: themastertaylor |
last post by:
I've got a system to manage various quotes for building materials for
a number of sites. i want a query to produce a report that shows me
who HASN'T quoted for which sites. basically so i can...
|
by: rfranzl |
last post by:
Hello,
I need some help, I have about 200 databases that are copies of an original database that has a similiar table in all of the databases, called "tblCodebook".
What I am trying to do is to...
|
by: rfranzl |
last post by:
Hello,
I need some help, I have about 200 databases that are copies of an original database that has a similiar table in all of the databases, called "tblCodebook".
What I am trying to do is to...
|
by: scolivas |
last post by:
Is there a way to automate this process?
I have a query that finds the "Drop Offs" by doing an unmatch query against the hard table and the live table.
I want to automatically pull these...
|
by: ilikebirds |
last post by:
In 1 Database(ttt) I currently have a Union Query that collects data from 4 databases (a,b,c,d) and then a MakeTable query that combines all of those into a table. ( Union A,B,C,D to make table in...
|
by: AccessHunter |
last post by:
Please Help....
I have a query with 2 tables, LegalFile and Cases.
LegalFile has the field CaseID(Number Field) and Cases has CaseNbr(Text Field).
I am trying to find entries that are in...
|
by: Tlou5831 |
last post by:
I am attempting to compare 2 tables in my DB and find unmatched criteria.
There are 2 different fields in each database that need to be compared.
Tbl_AppUsers
Role Settings
INQ ...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |