473,545 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL / JOIN problem in Access Report !

Hi,

In my Access Report ...
If there is "NO" entry i.e. (no corresponding CODE) in my Data-File,
then even the Master-File entry does not show up in the report.

eg.

Mast-File
Code Op.Bal
1 20
2 25
3 30
Data-File
Code Debit Credit
1 10
1 15
3 40
1 30
3 5
Report
Code Op.Bal
1 15
3 65
In my Access Report ... Code "2" never shows up as there is no entry in
the data file for it.

I have a field in my Access Report which is supposed to display the
final Op.Bal as :

Final Op.Bal = Op.Bal (from the mst-file) + debits - credits.

I am using a query as my record source built using the Query Designer
Grid.

My SQL is very weak ... could someone please post some simple SQL or
guide me how to modify my Query Design.

Hope I've been clear.

Thx & Best Rgds,
Prakash.

Nov 13 '05 #1
5 2901
Use an outer join between the two tables instead of an inner join.
Then use NZ or whatever to convert the null to a zero so you can do
math on it. Base your report on the query, not the table.

Nov 13 '05 #2
Thx Pietlin for the really prompt reply.

I'm real sorry ... but unfortunately I don't know how to write a join.
I'm from a Clipper background and have yet to learn SQL syntax.

Could you or someone else be kind enough to post the SQL here so that I
can modify my code accordingly ?

Thx & Best Rgds,
Prakash.
pi********@hotm ail.com wrote:
Use an outer join between the two tables instead of an inner join.
Then use NZ or whatever to convert the null to a zero so you can do
math on it. Base your report on the query, not the table.


Nov 13 '05 #3
DFS
Prakash wrote:
Hi,

In my Access Report ...
If there is "NO" entry i.e. (no corresponding CODE) in my Data-File,
then even the Master-File entry does not show up in the report.

eg.

Mast-File
Code Op.Bal
1 20
2 25
3 30
Data-File
Code Debit Credit
1 10
1 15
3 40
1 30
3 5
Report
Code Op.Bal
1 15
3 65
In my Access Report ... Code "2" never shows up as there is no entry
in the data file for it.

I have a field in my Access Report which is supposed to display the
final Op.Bal as :

Final Op.Bal = Op.Bal (from the mst-file) + debits - credits.

I am using a query as my record source built using the Query Designer
Grid.

My SQL is very weak ... could someone please post some simple SQL or
guide me how to modify my Query Design.

Hope I've been clear.

Thx & Best Rgds,
Prakash.


This might help, Prakash:

SELECT M.Code, M.OpeningBalanc e,
IIF(ISNULL(T.Su mDebits),0,T.Su mDebits) as Debits,
IIF(ISNULL(T.Su mCredits),0,T.S umCredits) as Credits,
M.OpeningBalanc e + (Debits - Credits) as EndBalance

FROM [Mast-File] M LEFT JOIN
(SELECT Code, Sum(Debits) AS SumDebits, Sum(Credits) AS SumCredits
FROM [Data-File]
WHERE TransDate Between #1/1/05# AND #3/5/05#
GROUP BY Code) T

ON M.Code = T.Code;

(note: I'm assuming your data-file table has transaction dates. If not,
delete that WHERE clause)

Also, this query might not run in Access97 - though it will in Access 2000
or later.

Nov 13 '05 #4
"Prakash" wrote
I'm real sorry ... but unfortunately I don't
know how to write a join. I'm from a
Clipper background and have yet to
learn SQL syntax.

One of the nice things about Access is that you can use it quite well
without knowing much of anything about SQL. Use the Access Query Builder...
you join table by clicking and dragging a field to the comparable field in
another table that you have added as a data source. Right-click the
resulting join line, and choose the appropriate option so you will see the
main table records even if there is not a related record.

But, a newsgroup is not the place for a basic tutorial on building queries
visually...

Check your local bookstore for a beginner-to-intermediate level Access book:
one I like for true novices with Access is Microsoft Press' _Microsoft
Access Step by Step_, another that goes much deeper is Microsoft Press'
_Access 2003 Inside Out_ by John Viescas.

Or, if you are using Access 2003, in the help pane click "Training" and
follow the links. If you aren't using 2003, the base URL is:
http://office.microsoft.com/en-us/training/default.aspx

You'll find (many) other resources at http://www.mvps.org/access and links
to resources at http://ntaccess.tripod.com.

Larry Linson
Microsoft Access MVP

Nov 13 '05 #5
DFS & Larry ... Thank you both for your replies.

Larry I have been using the Access Query Builder all along & since I've
been getting by I have'nt really taken the plunge to learn SQL. Yes, I
do own a few Access books but there isn't much on SQL there. These days
I'm not too much ino programming ... mostly marketing, but still
maintaining a few odd installations here & there.

Ok ... I did dbl-click on the join line & have used the 2nd option
where it says :
"Include all records from 'DPATMST' and only those records from
'DPATDAT' where the joined fields are equal."
In fact I tried this before I made a post here ino the NG but still the
Main Table record does not show up.

On examining DFS's code, I see he has made use of the ISNULL function.
Could that have made the difference ?

Unfortunately I'm in the interior and won't have access to my
application for the next 3 to 4 days.

Would one of you please be kind enough to correct the SQL code below to
make it work and also tell me how I can make the same modification into
the Query Builder (maybe using ISNULL if reqd) ... so that I do not
have to type in the SQL. This way maintaining & modifying the code in
future would be significantly easier for me.
SELECT DPATDAT.CODE, DPATMST.COMPANY , DPATDAT.INV_DAT E, DPATDAT.REF,
DPATDAT.DEBIT, DPATDAT.DETAILS , DPATDAT.CREDIT, DPATDAT.CLEARED ,
DPATDAT.TRAN_NO , DPATDAT.OMIT, DPATMST.ADDR1, DPATMST.ADDR2,
DPATMST.ADDR3, DPATMST.MON_REN T, DPATMST.AGR_FRO M, DPATMST.AGR_TO,
DPATMST.OPBAL
FROM DPATMST LEFT JOIN DPATDAT ON DPATMST.CODE = DPATDAT.CODE
ORDER BY DPATDAT.TRAN_NO ;
And oh yes ... I am using Access XP (2002).

Once again ... thx so much for your help.
Best Rgds,
Prakash.

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
6122
by: Dave M | last post by:
All I've got a database that keeps track of sales of widgets. Each company that belongs to my organiztion is to report their widget sales or no sales every month. There are several different types of widgets. Not all companies sell or report all types of widgets. We want to report how many companies have reported or not reported their
7
11181
by: steve | last post by:
Can you join two tables across different servers in mySQL, or am I dreaming of Oracle? -- Posted using the http://www.dbforumz.com interface, at author's request Articles individually checked for conformance to usenet standards Topic URL: http://www.dbforumz.com/mySQL-Join-servers-ftopict225285.html Visit Topic URL to contact author (reg....
9
3198
by: Alan Lane | last post by:
Hello world: Background: Yesterday, January 21, Doug Steele was kind enough to help me out on a Left Join problem. I was trying to return all stores and their Gross Adds for December, 2004 (even though some of them had no Gross Adds for that month). My query would only show the non-zero GA stores. Doug stated "It's because of the Where...
6
6289
by: davegb | last post by:
I'm trying to create a self-join table to show the relationship between employee and supervisor. In another thread, I was advised to create a SupervisorID in the employee table, a separate Supervisor table, and join the Supervisor table to the Employee table and a copy of the Supervisor table to create the self-join. I can't figure out how to...
26
2149
by: Jeff | last post by:
Ok gang. Here is something complicated, well, at least to me anyway. Using Access DB I have a table in my DB called members. In that table, I have 2 tables I will be using "username" and "points" Now, I also have a table called all_matches. This table contains every match report. Over 25,000 of them. I have a "username" field an...
9
2514
by: Fish Womper | last post by:
I am at best a part time developer of Access databases. I use Access 2.0, as this is all my employer has on its computers. Even so, to use this ancient version requires a fairly convoluted installation procedure on each PC on which it is used. I am self-taught from the help files that come with Access 2.0 and from painful experience. I've...
4
2082
by: kamin | last post by:
I have this query select created_date, tyg_aging_due_dates.object_type, tyg_aging_due_dates.due_date from #tyg_aging_service_metrics right join tyg_aging_due_dates
3
7971
by: pritampatil | last post by:
Hi All, I tried to run the attached query in MS-Access but its giving error "Join expression not supported" I am unable to find the cause of it till now, please try to find the same and help me. access query ---------------------------------------- SELECT dbo_CAS_CLM_MAST_TB.TRACKING_NO AS , dbo_CAS_CLM_MAST_TB.ACCOUNT_NO AS , ...
6
51525
by: Avaenuha | last post by:
I need to use a left outer join to get all of one table, and match it to specific instances of another table. Eg, report all of A, and where A has made a specific kind of B, report the name of that B. Now, to get the specific B, I need to join three other relations together, and then do a string match. That's easy. I can report the subset of A...
0
7487
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7934
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7446
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6003
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5349
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.