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

Querying joined tables for blank records

Hi,

I'm having trouble with a query and have been searching through numerous sites but am struggling to find anything or know exactly what to look for. Here's the scenario.

I have two tables, Clients and Calls, related by a unique field in the Clients table of "Client ID".
As calls are made to the clients the Calls table fills up with each record including the "Clients.Client ID" number. My problem is I would like to make a query that shows fields from the Clients table that have NO related records in the Calls table (ie that have no "Client ID" number in the Calls table).

When I make a query with these two tables it shows up with nothing in the datasheet view (as currently there are no related records in the calls). I need it the other way around. To show all fields in the Clients table with no related records.

I have Access 2003 on Windows XP. I have limited experience with coding and what I do know is old and stuffed in the back of my brain but welcome any suggestions with or without code, if this even possible.

I hope this makes sense to you and thanks for your help in advance.
Feb 23 '07 #1
6 2940
Michael R
176 100+
When I make a query with these two tables it shows up with nothing in the datasheet view (as currently there are no related records in the calls). I need it the other way around. To show all fields in the Clients table with no related records.
Add the following line to your query cretiria. (Change the names in the line if necessary)
DCount("Call_Id","Calls","Client_Id=" & [Client_ID])="0"
Feb 23 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
This should do it ...

Expand|Select|Wrap|Line Numbers
  1. SELECT Clients.* 
  2. FROM Clients LEFT JOIN Calls
  3. ON Clients.ClientID=Calls.CallsID
  4. WHERE Calls.CallsID Is Null;
Mary
Feb 23 '07 #3
Thanks for your help so far but I'm sorry you'll have to bare with me. Michael R, I tried your code but wasn't sure which Client ID was refering to which table and exactly how to design the query to accommodate. If it helps I'll clarify my tables:

CLIENTS
*Client ID (relation:1)
Business Name
Contact
Phone Number
etc.

CALLS
*Call ID
Client ID (relation:many)
Date of call
etc.

mmcarthy, sorry I'm a bit undereducated/rusty. Where do I put your code?

Thanks again.
Feb 23 '07 #4
Wait don't worry. I found it. mmccarthy, I found where to put your code and with a bit of playing it worked. Thank you so much. I just have to be careful not to put spaces in field names when using SQL.
Feb 23 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Wait don't worry. I found it. mmccarthy, I found where to put your code and with a bit of playing it worked. Thank you so much. I just have to be careful not to put spaces in field names when using SQL.
True. To get around it just put square brackets around the field or table name like [Client ID].

Glad it's working for you.

Mary
Feb 23 '07 #6
NeoPa
32,556 Expert Mod 16PB
Wait don't worry. I found it. mmccarthy, I found where to put your code and with a bit of playing it worked. Thank you so much. I just have to be careful not to put spaces in field names when using SQL.
You're right though. Although you can get around it with the square brackets ([]) it is much better practice to avoid spaces and punctuation characters in names.
Feb 26 '07 #7

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

Similar topics

1
by: anmar | last post by:
I'm trying to figure out how to select all the records in one table which have multiple specified records in a second table. Here's a simplified version of my problem. I have two tables,...
6
by: Greg | last post by:
I am working on a project that will have about 500,000 records in an XML document. This document will need to be queried with XPath, and records will need to be updated. I was thinking about...
1
by: Carl B Davis | last post by:
Help please!!! I am an intermediate access user that is getting my bottom kicked by what seems an easy problem to fix. I maintain an employee database at work. I have set up a query from two tables...
8
by: Paul | last post by:
I have an application that I am tryign to modify, I never wrote the original so need help with my modifications. Currently the app reads and writes to an Access database with one table 'pupils'...
3
by: loosecannon_1 | last post by:
I get a 90-120 second blocking when send 15 or so simultaneous queries to SQL Server 2000 that query a view made up of two joined tables. After each query is blocking for the same amount of time...
2
by: commanderjason | last post by:
This seems like a very simple question but i have never been able to find an easy answer to it. I have a user table and i do a join with another table, we'll call the other table a results...
4
by: Frank List | last post by:
Hi, I've run into this problem many times and have not found a good solution yet. Here's what I have: table ParentTable - the "1" table table ChildTable- the "many" table ParentTable...
6
by: John | last post by:
Hi I have three tables with a common id with which they can be linked. I need to merge them in a way that the resultant table has all records from three tables. Below is what sort of result I am...
1
by: SilRay | last post by:
I will admit up front that this is to help with an assignment for a class, however, I'm looking for information outside the scope of the assignment because I want to do something cooler. The...
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: 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
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
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,...
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...

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.