473,379 Members | 1,245 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,379 software developers and data experts.

Reporting problem with multiple tables?

283 100+
Hello all,

Im having a problem getting a report to work with multiple tables.

First let me give a little detail in to how im doing this. I am using a form to pull the report. I have a report linked to 3 tables by a persons name. If you type in the persons name, along with a date range (from the form) then run the report it pulls the information from all 3 tables together and gives you the output. It actually works fine but my problem is when one of the tables does not have the persons name.

The main table is a list of all the names (along with other info). Now the second and third table contain errors (along with a date) that a person has made from the main table, but not everyone makes errors so both of the tables may not contain errors for the person, which is the problem. If all 3 tables have the persons name the report works fine, if i remove a name from one of the tables the report errors out. How can i make it still pull all of the info even if all the tables do not contain the persons name??

So an example would be if table 2 has errors for John Smith but table 3 does not, how to still pull the info?

Thanks in advance!!
Feb 13 '11 #1
4 1765
TheSmileyCoder
2,322 Expert Mod 2GB
If you join 2 tables in the query window, (by PersonID for example) and one of them does not contain a record with PersonID the result from the other table will not be shown.

Now, If you require that your results from the main table are always shown, the solution is to LEFT join the the 2 other tables. In the query window, you can click the join between the 2 tables to modify the join type (Standard join is both ways) to either a LEFT or a RIGHT join. A one sided join will select all the records from 1 table, and only the matching records from the other table.
Feb 14 '11 #2
slenish
283 100+
Hi TSO,

I tried what you suggested with the left join but im not quite getting the results i would like. It works but only when the main table and the secondary table are in the same date range i get all the results but if only the secondary table is in the date range im trying to check i get nothing.

Is there a way to show the results of the secondary table with out the primary table having a match?

Im attaching an example db to show you what i have been working with.

Thanks for the help on this :D
Attached Files
File Type: zip ReportMultiTable.zip (40.1 KB, 87 views)
Feb 14 '11 #3
TheSmileyCoder
2,322 Expert Mod 2GB
I have modified the example DB you provided, to show what I meant.

A few unrelated observations:
You should join the table by the ID of the person(The Primary Key), not their name.

Why do you join on the date? Are errors only relevant if they have happened on the same date?
Attached Files
File Type: zip ReportMultiTableEdit.zip (16.5 KB, 89 views)
Feb 14 '11 #4
slenish
283 100+
Hi TSO,

Appreciate you taking the time to make some changes. Its close to what i was trying to accomplish.

The reason i was trying to join on the date was because i wasn't sure if that might help when i pull for a date range.

As of right now if I put in the persons name and a date range say Feb 1 - Feb 28 then I want it to pull all the errors for that date range for the person, but instead its pulling everything. If you look at table 3 the date is set for January. So what i want it to do is if i pull Jan 1 - 31 then it shows me only the table 3 records, if i pull Feb 1 - 28 then it will only show me the table 2 records or if both tables have records in the same date range then show me all the records. Is it possible to do this? I keep playing around with the left and right join trying all kinds of combinations but nothing seems to work.

I could set up the ID as the primary key but would that make a difference for what im trying to do? I'm guessing not...

====Update====
Hi TSO,

Ok i have been playing around with this some more and i figured out how to make it work the way i want. I put in a sub report and linked that to table 3 and it works great. Now the problem im having is trying to get the main report Name box to contain the name of the person...Im attaching my update for you to take a look at.

Hope to hear from you soon :D
Attached Files
File Type: zip ReportMultiTable.zip (79.4 KB, 89 views)
Feb 14 '11 #5

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

Similar topics

1
by: TeleTech1212 | last post by:
I am trying to select specific columns from multiple tables based on a common identifier found in each table. For example, the three tables: PUBACC_AC PUBACC_AM PUBACC_AN each have a...
1
by: cr113 | last post by:
Suppose you have the following 2 database tables: Table1 - primary key = Field1 Field1 Field2 a 1 b 2 c 2
11
by: Randy Harris | last post by:
I have been using "IN" to query tables in Oracle from MS Access very successfully. Select Field FROM MyTable IN [ODBC...etc Works great if there is only one table involved. Anyone know how I...
0
by: sam | last post by:
I always create one new class for one table in order to connect it via wizard. So,I had created ten classes for ten tables. Can you teache me how to create one new class which it can connect to...
0
by: ts | last post by:
Hi! With asp.net and c#, i want to display data from multiple tables in a datagrid. Using a DataView is one way to go, but is this the standard way to accomplish this? Are there any articles...
1
by: Nikolay Petrov | last post by:
How to fill dataset with multiple tables and set their relaition? Can I get the relations from the SQL server? Also I would like to do it using stored procedures. TIA
2
by: Gugale at Lincoln | last post by:
Hi, I have generated a typed dataset containing two tables in vs2005. Tables have one to many relationship. I would like to populate both the tables using preferably just one call to stored...
0
by: John | last post by:
Hi Its easy to trap errors such as concurrency error when a single table is involved with code similar to this; Try Me.MytblAdpater.Update(DS.Mytbl) Catch dbcx As...
4
by: knix | last post by:
I have this access project consisting of multiple tables that are linked together in a relationship. I would like to migrate the consolidated information through appending in a datasheet form or...
1
by: Andrea | last post by:
I have a data structure composed with a dataset with multiple tables connected through relationship. I'm using different table adapters of the dataset for load table, but when i use the select...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.