Access 2007 3 table query: Contact table, Event table, Payment table. Contact may have an Event but no Payment, a Payment but no Event, or an Event and Payment. My query is duplicating the Event and Payments. I have attached an example: The Contact Smith has 2 Events (Rome night and Men club) and 2 Payments ($4000 and $100) that are not associated. I want the query to return 4 records: 2 showing the Payments with associated Contact info (with nothing in the Event fieelds) and 2 showing the Events with associated Contact info (with nothing in the Payments fields.
I can copy and paste SQL with instruction but don't know how to write it.
** Edit ** ![](https://bytes.com/attachments/attachment/4571d1295202541/sampleqryresults.jpg) 6 2619
Why not just create two queries in the query wizard, one to show events and one to show payments?
Wizard is easiest for simple queries I think.
I need one query that shows ALL Contacts and ANY Payments and/or ANY Events they may have.
mshmyob 904
Recognized Expert Contributor
Go into the SQL view and copy/paste your SQL.
cheers,
- SELECT DISTINCTROW [CONTACT DEMOGRAPHICS].CID, [CONTACT DEMOGRAPHICS].SOURCE, [CONTACT DEMOGRAPHICS].LastName, [CONTACT DEMOGRAPHICS].FirstName, [CONTACT DEMOGRAPHICS].Address, Event.EID, Event.[Contact ID Number] AS [Event_Contact ID Number], Event.[Date OF Event], Payments.PID, Payments.[CONTACT ID NUMBER] AS [Payments_CONTACT ID NUMBER], Payments.DatePaymentEntered, Payments.PaymentAmount, Payments.DirectFundsTo, IIf([paymentamount]=4000,"",[name of event]) AS Expr1
-
FROM ([CONTACT DEMOGRAPHICS] LEFT JOIN Payments ON [CONTACT DEMOGRAPHICS].CID = Payments.[CONTACT ID NUMBER]) LEFT JOIN Event ON [CONTACT DEMOGRAPHICS].CID = Event.[Contact ID Number];
NeoPa 32,571
Recognized Expert Moderator MVP
Fundamentally, you need to join the Event and Payment data together by using a UNION query, then JOIN this data to your Contact table on the right side of a LEFT JOIN. The Event and Payment data in the UNION query part would need to occupy separate fields.
NeoPa - got it right!!!! thanks.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: rickcross |
last post by:
I am trying to use the Access 2007 runtime. I have a program that is
fully working in 2007 but when I install the runtime version with same
Operating system and Access 2003 installed I have multiple errors.
One error "Function is not available in table level validation
expression."
This error occurs three times. when I have a two part delete query or
a lookup function that checks for a duplicate entry and a update
query that adds a...
|
by: LadyIlsebet |
last post by:
I'm not a fantastic Access developer, but I'm trying to help get
Inventory and whatnot organized at work. They are used to 5 year
budget plans that list out exactly what has to be purchased what year
and how much it will cost. Currently these are kept in Excel and look
like this
| Inventory information (who, what, where) | 2008 | 2009 | 2010 |
2011| 2012
The cost for the item is displayed in the column in the year when it
|
by: Sport Girl |
last post by:
Hi everybody , I have this query in SQL using Access 2007:
SELECT Count(Opportunities.Won) AS CountOfWon, Count(Opportunities.Lost) AS CountOfLost, Count(Opportunities.) AS , Opportunities.System
FROM Opportunities
WHERE ((("Opportunities.Won")=True)) OR ((("Opportunities.Lost")=True)) OR ((("Opportunities.")=True))
GROUP BY Opportunities.System;
|
by: lisacrowe |
last post by:
I have a simple database recording complaints. A crosstab query is based on a query which returns resolved complaints only. The crosstab has the field Complaint Type as a row heading and Outcome as a column heading.
I want to be able to select complaints which were resolved in a particular date range (field is Date resolved). This field is in the original query but not the crosstab.
How do I do it?
|
by: sphinney |
last post by:
Basic question:
Does anyone know how to go about adding a control to an Access 2007 form that will allow viewing a Word 2007 document?
Reason for asking:
My office is about to receive 100+/- Word 2007 documents that contain data that needs to be imported into various fields of an Access 2007 table. To facilitate the import process, I was thinking of creating a form in Access that would have a Word control (or "window") at the bottom of the...
| |
by: Anthony97 |
last post by:
I ran this code on my access 07 db and it updates a number of records 61,425, I try and run the query in SQL Server 2005 modifying the IIf to CASE WHEN and I get a number of sytax errors.
Original code
UPDATE tblShipments
SET tblShipments. = IIf( Like "web*","WEB",
IIf(=1,"EDI",IIf( Is Null,"MAN","EDI")));
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'Like'.
|
by: brat33 |
last post by:
I am trying to modify some code to create a mail merged label document within Word 2007, using a Access 2007 Parameter Field. My issue comes about when I cannot see the Parameter Query within the selecting list in Word. I would rather not have 40 queries for each year we are pulling, so I want to use the parameter query to simplify things.
I have thought using a Temp. Table and pulling from there - but have no clue as to how to go about...
|
by: mulamootil |
last post by:
Hey guys - Is there a way to wrap the text in the header field in an Access 2007 table. I did some googling, however no luck, thought I will post it here. I sure appreciate your time and help.
stan
|
by: sentimental37 |
last post by:
I want to create a table in access 2007 by query not in design view. My table should look like;
Serial AutoNumber
Name Text
Country Text
I am using the following query:
CREATE TABLE Details (Serial AutoNumber, Name TEXT, Country Text)
But its returning an error (Sysntax error in field definition ) with AutoNumber Highlighted .Plzz help
|
by: enia atsir |
last post by:
Hi,
I have built a cross tab query Account_ID as row heading and month_year as column heading.
I need to find if an account is at one year and not in the next month.For example: 07_2010 is not null, 08_2010 is null, 09_2010 is not null.
I have 30 months in total and is difficult to make all needed combination.
Please can someone help me how to resolve this?
Thnx
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
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: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |