473,395 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Showing records with no data.

111 100+
Hello,
I have a situation as follows.
1. There is field called Project ID which has several Resource categories. Each Resource category has either few amounts of money in different categories or it does not have any amount of money.
2. I am pulling out a report which shows the data related to the resource categories for a specific project ID.
3. My problem is it does not show the resource categories which do not have any data in. Suppose ProjectID: 12ABC1234 has 4 Resource Categories,
RC1: 1A1, it has related data
RC2: 2B2, it has related data
RC3: 3C3, there is nothing associated with category
RC4: 4E4, there is nothing associated with category
My question is how can I show RC3 and RC 4 in my report with the data rows saying N/A or $0??
Thanks.
The query I am currently using is
Expand|Select|Wrap|Line Numbers
  1. SELECT lkptbl_ProjectID.ProjectID, Draws.[Grant/Budget Index], Draws.DrawDate, lkptbl_ResourceCategory.ResourceCategory, Budget.[federal calculated total] AS AuthorizedBudgetCoastal, Sum([match calculated total]+[other calculated total]) AS AuthorizedBudgetMatch, Draws.DrawTotalFed AS CurrentDrawCoastal, Draws.DrawTotalMatch AS CurrentDrawMatch, lkptbl_ResourceCategory.ResourceCategoryID, [Grant Information].[data entry date]
  2. FROM lkptbl_ResourceCategory INNER JOIN (lkptbl_ProjectID INNER JOIN ((([Grant Information] LEFT JOIN Budget ON [Grant Information].[Grant Index] = Budget.[Grant/Budget Index]) INNER JOIN qryDrawsTotal ON [Grant Information].[Grant Index] = qryDrawsTotal.[Grant/Budget Index]) LEFT JOIN Draws ON [Grant Information].[Grant Index] = Draws.[Grant/Budget Index]) ON lkptbl_ProjectID.ProjectID_ID = [Grant Information].ProjectID_ID) ON lkptbl_ResourceCategory.ResourceCategoryID = [Grant Information].ResourceCategoryID
  3. GROUP BY lkptbl_ProjectID.ProjectID, Draws.[Grant/Budget Index], Draws.DrawDate, lkptbl_ResourceCategory.ResourceCategory, Budget.[federal calculated total], Draws.DrawTotalFed, Draws.DrawTotalMatch, lkptbl_ResourceCategory.ResourceCategoryID, lkptbl_ProjectID.ProjectID_ID, [Grant Information].[data entry date]
  4. HAVING (((lkptbl_ResourceCategory.ResourceCategoryID)=[forms]![frmSearchFinancialRpt]![cmbResourceCat]) AND (([Grant Information].[data entry date]) Between [forms]![frmSearchFinancialRpt]![txtStartDate] And [forms]![frmSearchFinancialRpt]![txtEndDate])) OR (((lkptbl_ProjectID.ProjectID_ID)=[forms]![frmSearchFinancialRpt]![cmbProjectID]))
  5. ORDER BY Draws.DrawDate;
  6.  
Jul 23 '10 #1
10 1427
NeoPa
32,556 Expert Mod 16PB
Somewhere in your FROM clause you have an INNER JOIN where you need a LEFT JOIN. See SQL JOINs for more on this.
Jul 23 '10 #2
patjones
931 Expert 512MB
I'm going to say that you would want to change your FROM clause to utilize a LEFT JOIN on resource category:

Expand|Select|Wrap|Line Numbers
  1. FROM lkptbl_ResourceCategory LEFT JOIN (lkptbl_ProjectID INNER JOIN ((([Grant Information] LEFT JOIN Budget ON [Grant Information].[Grant Index] = Budget.[Grant/Budget Index]) INNER JOIN qryDrawsTotal ON [Grant Information].[Grant Index] = qryDrawsTotal.[Grant/Budget Index]) LEFT JOIN Draws ON [Grant Information].[Grant Index] = Draws.[Grant/Budget Index]) ON lkptbl_ProjectID.ProjectID_ID = [Grant Information].ProjectID_ID) ON lkptbl_ResourceCategory.ResourceCategoryID = [Grant Information].ResourceCategoryID

Pat
Jul 25 '10 #3
AccessBeetle
111 100+
It gave me error. To solve that I created another query to create a left join and then put that qury in this query. So now it looks like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT lkptbl_ProjectID.ProjectID, Draws.[Grant/Budget Index], Draws.DrawDate, Budget.[federal calculated total] AS AuthorizedBudgetCoastal, Sum([match calculated total]+[other calculated total]) AS AuthorizedBudgetMatch, Draws.DrawTotalFed AS CurrentDrawCoastal, Draws.DrawTotalMatch AS CurrentDrawMatch, qryFinancialRptLeftJoin.ResourceCategoryID
  2. FROM (((lkptbl_ProjectID INNER JOIN qryFinancialRptLeftJoin ON lkptbl_ProjectID.ProjectID_ID = qryFinancialRptLeftJoin.ProjectID_ID) LEFT JOIN Draws ON qryFinancialRptLeftJoin.[Grant Index] = Draws.[Grant/Budget Index]) INNER JOIN Budget ON qryFinancialRptLeftJoin.[Grant Index] = Budget.[Grant/Budget Index]) LEFT JOIN qryDrawsTotal ON qryFinancialRptLeftJoin.[Grant Index] = qryDrawsTotal.[Grant/Budget Index]
  3. GROUP BY lkptbl_ProjectID.ProjectID, Draws.[Grant/Budget Index], Draws.DrawDate, Budget.[federal calculated total], Draws.DrawTotalFed, Draws.DrawTotalMatch, qryFinancialRptLeftJoin.ResourceCategoryID, lkptbl_ProjectID.ProjectID_ID
  4. HAVING (((qryFinancialRptLeftJoin.ResourceCategoryID)=[forms]![frmSearchFinancialRpt]![cmbResourceCat])) OR (((lkptbl_ProjectID.ProjectID_ID)=[forms]![frmSearchFinancialRpt]![cmbProjectID]))
  5. ORDER BY Draws.DrawDate;
  6.  
Now if I run the report it asks me Enter Parameter Value for Resource Category. ??
Why is that? Is there anything wrong in this query?
Here is the qryFinancialRptLeftJoin
Expand|Select|Wrap|Line Numbers
  1. SELECT lkptbl_ResourceCategory.ResourceCategoryID, lkptbl_ResourceCategory.ResourceCategory, lkptbl_ResourceCategory.ResourceCategoryDescription, [Grant Information].[Grant Index], [Grant Information].Status, [Grant Information].RecipientLongName, [Grant Information].RecipientShortName, [Grant Information].[project long title], [Grant Information].[project short title], [Grant Information].[Grant Year], [Grant Information].[CZMA section number], [Grant Information].[type of grant], [Grant Information].Reprogrammed, [Grant Information].extension, [Grant Information].[PDC Federal district], [Grant Information].[PDC State Senate district], [Grant Information].[PDC State House district], [Grant Information].[Staff Index], [Grant Information].Contact1Index, [Grant Information].Contact2Index, [Grant Information].ContactFiscal1Index, [Grant Information].ContactFiscal2Index, [Grant Information].OfficialRepIndex, [Grant Information].OCMFiscal1Index, [Grant Information].ContactCounty, [Grant Information].[project length], [Grant Information].[Tributary strategy issue area], [Grant Information].[Riparian Buffer project issue area], [Grant Information].[GIS project issue area], [Grant Information].[date 306A documentation to NOAA], [Grant Information].[306A NOAA approval date], [Grant Information].[subcontract approval notification], [Grant Information].[subcontract approval required], [Grant Information].[subapproval notification date], [Grant Information].[Impact area], [Grant Information].[project summary], [Grant Information].deliverables, [Grant Information].[data entry date], [Grant Information].[temporary field], [Grant Information].ManagementArea, [Grant Information].[federal returned], [Grant Information].ProjectType, [Grant Information].Acreage, [Grant Information].DistancePreserved, [Grant Information].Competitive, [Grant Information].PublicAccess, [Grant Information].CoastalHabitat, [Grant Information].WaterQuality, [Grant Information].CoastalHazards, [Grant Information].CoastalDependentUses, [Grant Information].UTMEasting, [Grant Information].UTMNorthing, [Grant Information].ResourceTypeID, [Grant Information].ResourceSubcategoryID, [Grant Information].ProjectID_ID, [Grant Information].ActivityCodeID, [Grant Information].GrantNumber, [Grant Information].ProjectTypeNo
  2. FROM lkptbl_ResourceCategory LEFT JOIN [Grant Information] ON lkptbl_ResourceCategory.ResourceCategoryID = [Grant Information].ResourceCategoryID;
  3.  
Jul 26 '10 #4
patjones
931 Expert 512MB
Well what was the error that resulted from switching to a LEFT JOIN as I outlined in post #3? Perhaps we can still work with that rather than embedding a query within a query.

Pat
Jul 26 '10 #5
AccessBeetle
111 100+
The error is "the sql statement could not be executed because it contains ambiguous outer joins"
Jul 26 '10 #6
NeoPa
32,556 Expert Mod 16PB
Jet SQL will not support OUTER JOINs (LEFT JOIN or RIGHT JOIN) to join any groups which include INNER JOINs.

IE. A INNER JOIN B LEFT JOIN C is ok, but A INNER JOIN B LEFT JOIN C INNER JOIN D is not.
Jul 26 '10 #7
AccessBeetle
111 100+
Neopa,
Should I go on the path I mentioned on Post #4 or is it not possible?(I guess it must be possible somehow!!I don't know)
Thanks
Jul 27 '10 #8
NeoPa
32,556 Expert Mod 16PB
My thoughts were that you need to go through your FROM clause and find the offending JOIN. Frankly your SQL is very complicated and not well displayed. A nightmare to trawl through. Your effort would best be served simplifying it where possible, and this would start by displaying it in such a way that you can see more easily what connects with what.

I can only really tell you the concepts you need to consider when designing it. I'm afraid I cannot make comments that depend on my understanding what your SQL is trying to do (other than run). My advice would always be to simplify and clarify, rather than to look for ways of avoiding the problem. That way it will only catch you another time.
Jul 27 '10 #9
AccessBeetle
111 100+
Thanks for the advise and thanks for looking into it.
I am trying to solve it, I hope I will one day!!
Wish me luck..
Jul 27 '10 #10
NeoPa
32,556 Expert Mod 16PB
Good luck :)

BTW Look for the following in your FROM clause as an example of exactly what I was talking about :
Expand|Select|Wrap|Line Numbers
  1. ([Grant Information] LEFT JOIN Budget ON [Grant Information].[Grant Index] = Budget.[Grant/Budget Index]) INNER JOIN
Jul 28 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: PaulMac | last post by:
This seems so easy....change the join to show all records, but the zero records still do not show I want to join 2 tables....basically Customers and Orders....get the total number of orders for...
0
by: John Baker | last post by:
Hi: On forms, at the top of the screen menu, there is an entry records/data entry, which i wish to replicate in a macro or code. I would also like to be able to revert to normal mode. Can...
1
by: Kenny M. | last post by:
Hi I have a SqlDataReader getting 1000 records from a table and showing it into a DataGrid (via binding) It looks like Rec1 Rec2 Rec3 ......
1
by: syedrafey | last post by:
Hello, One of datagrid on my aspx page is not showing records on production server while there are records in database table. I have tested that page on my local machine and it is working fine....
1
by: RLau | last post by:
Hi All, I have created a form and subform ( Assignee Outstanding Form ) to display records and related notes in a Helpdesk database table by the assignees respectively. Now, instead of clicking...
4
by: dac | last post by:
I am quietly going insane on this project. I've never worked on a project like this one before. All my previous sticky forms were for data entry, not editing. I don't know how to display the form...
1
by: webcat | last post by:
hi all, how about this? I want to allow users to click a check box on a form to 'flag for testing' thats fine - works great but what if there is 100 records and the user wants to flag...
2
by: ilikebirds | last post by:
Access 2003: I notice that on a form there is a menu for RECORDS - Data Entry. What occurs here is when data is updated and the option is selected It enters the data into the table and starts...
1
by: latanivandikar | last post by:
In asp.net How to display records satisfying particular conditions from one table only in diff DIV eg. using only one table we have to display diff. records in diff.DIV. according to...
5
by: JHite | last post by:
I’m using Access 2003 on Windows XP. I have a Mainform (Staff Entry) which displays an unbound combo box named ChooseStaff. The Row Source for this combo box is a SELECT of the UserIDs and Staffer...
0
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...
0
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...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.