A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

I can't figure out how to do this.



 
 
Thread Tools Display Modes
  #1  
Old November 18th, 2009, 04:47 AM posted to microsoft.public.access.queries
SF[_5_]
external usenet poster
 
Posts: 27
Default I can't figure out how to do this.

Hi,

I can't figure out how to do this. I want to check if staff is available in
the office by create query from TravelTable (TravelID, EmployeeID,
TravelDateFrom, TravelDateTo).
The query should list anyone who are not travelling today. Would it be
possible or not?

SF


  #2  
Old November 18th, 2009, 11:25 AM posted to microsoft.public.access.queries
Krzysztof Naworyta
external usenet poster
 
Posts: 80
Default I can't figure out how to do this.

SF wrote:

| I can't figure out how to do this. I want to check if staff is
| available in the office by create query from TravelTable (TravelID,
| EmployeeID, TravelDateFrom, TravelDateTo).
| The query should list anyone who are not travelling today. Would it be
| possible or not?

It is possible

--
KN
  #3  
Old November 18th, 2009, 12:59 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default I can't figure out how to do this.

Assuming you have an Employee table, this is possible

The basic idea is to create a query that shows everyone that IS traveling on
the date specified and then use that query to get everyone that is not traveling.

This query should get everyone that is traveling today
SELECT EmployeeID
FROM TravelTable
WHERE Date() Between TravelDateFrom and TravelDateTo

So, the following should work to give you employees not traveling.

SELECT *
FROM EmployeeTable
WHERE EmployeeID NOT IN
(SELECT EmployeeID
FROM TravelTable
WHERE Date() Between TravelDateFrom and TravelDateTo)

You can also use
SELECT *
FROM EmployeeTable
WHERE EmployeeID NOT EXISTS
(SELECT *
FROM TravelTable
WHERE Date() Between TravelDateFrom and TravelDateTo
AND TravelTable.EmployeeID = EmployeeTable.EmployeeID)

Or other variations are available.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

SF wrote:
Hi,

I can't figure out how to do this. I want to check if staff is available in
the office by create query from TravelTable (TravelID, EmployeeID,
TravelDateFrom, TravelDateTo).
The query should list anyone who are not travelling today. Would it be
possible or not?

SF


  #4  
Old November 19th, 2009, 03:00 AM posted to microsoft.public.access.queries
SF[_5_]
external usenet poster
 
Posts: 27
Default I can't figure out how to do this.

Thank you for your tip. I will try that.

SF


"John Spencer" wrote in message
...
Assuming you have an Employee table, this is possible

The basic idea is to create a query that shows everyone that IS traveling
on the date specified and then use that query to get everyone that is not
traveling.

This query should get everyone that is traveling today
SELECT EmployeeID
FROM TravelTable
WHERE Date() Between TravelDateFrom and TravelDateTo

So, the following should work to give you employees not traveling.

SELECT *
FROM EmployeeTable
WHERE EmployeeID NOT IN
(SELECT EmployeeID
FROM TravelTable
WHERE Date() Between TravelDateFrom and TravelDateTo)

You can also use
SELECT *
FROM EmployeeTable
WHERE EmployeeID NOT EXISTS
(SELECT *
FROM TravelTable
WHERE Date() Between TravelDateFrom and TravelDateTo
AND TravelTable.EmployeeID = EmployeeTable.EmployeeID)

Or other variations are available.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

SF wrote:
Hi,

I can't figure out how to do this. I want to check if staff is available
in the office by create query from TravelTable (TravelID, EmployeeID,
TravelDateFrom, TravelDateTo).
The query should list anyone who are not travelling today. Would it be
possible or not?

SF



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:36 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.