Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-14-2012, 02:38 AM
jillapass jillapass is offline Multiple queries on table Windows 7 32bit Multiple queries on table Office 2007
Novice
Multiple queries on table
 
Join Date: Dec 2011
Posts: 26
jillapass is on a distinguished road
Default Multiple queries on table

I am trying to create a report as follows, but don't know how to.

I have a list of bookings and I find all the bookings for a particular week.


No problem there.

Then, I want to use the client for each of these bookings and find out all the bookings previously for this client, but only for clients who have a booking for the specified week.

So, to clarify, for next week I have 127 bookings and for each of these bookings I want to see if the client has booked previously.

Currently I am just finding the bookings for the specified week, but don't know how to do the 2nd query.

I guess what I need is to do a 2nd WHERE statement which is different from the 1st one, but on the same table.
Thanks fir any help.
Reply With Quote
  #2  
Old 09-16-2012, 04:14 AM
macropod's Avatar
macropod macropod is offline Multiple queries on table Windows 7 64bit Multiple queries on table Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi jillapass,

Perhaps a simple COUNTIF against the main list for each booking will do. If the count is greater than 1, that indicates a prior booking.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-17-2012, 01:07 AM
jillapass jillapass is offline Multiple queries on table Windows 7 32bit Multiple queries on table Office 2007
Novice
Multiple queries on table
 
Join Date: Dec 2011
Posts: 26
jillapass is on a distinguished road
Default

I can see what you are saying, but after I find the list of bookings for the week specificed with 'wk_com = ?' I only also need to find the entries where 'wk_com<?'.
Then I could use the count.
The trouble is that if I go straigt for 'wk_com<=?' then I also get the entries that do not have a booking for the specificed week.
I have been told I need to do a sub query, but I have never done one of these and wouldn't really know where to start.
Reply With Quote
  #4  
Old 09-17-2012, 01:14 AM
macropod's Avatar
macropod macropod is offline Multiple queries on table Windows 7 64bit Multiple queries on table Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi jillapass,

As I haven't seen your workbook, I have no idea what 'wk_com' relates to.

Can you attach a workbook to a post with some representative data (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 09-17-2012, 01:29 AM
jillapass jillapass is offline Multiple queries on table Windows 7 32bit Multiple queries on table Office 2007
Novice
Multiple queries on table
 
Join Date: Dec 2011
Posts: 26
jillapass is on a distinguished road
Default

Sorry, wk_com is a date of start of booking.
It wouldn't make much sense to attach the workbook as the data is in an SQL database so all the workbook contains is a list of bookings for a specified week with the client number and carer number, nothing else at all.
So, the select finds the bookings for a week, I then want to find any previous booking for clients that are already in this list, but these are in the same table.


The query I have is:

Code:
SELECT tblBookingsWarehouse.Wk_Com, tblBookingsWarehouse.CarerNo, tblBookingsWarehouse."Client Number"
FROM ch_warehouse.dbo.tblBookingsWarehouse tblBookingsWarehouse
WHERE (tblBookingsWarehouse.Wk_Com=?) AND (tblBookingsWarehouse.Type='Booking')
ORDER BY tblBookingsWarehouse.CarerNo
Reply With Quote
  #6  
Old 09-17-2012, 03:36 AM
macropod's Avatar
macropod macropod is offline Multiple queries on table Windows 7 64bit Multiple queries on table Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I'm not well versed in SQL, but it seems to me there should be an equivalent of tblBookingsWarehouse.Wk_Com (maybe tblBookingsWarehouse.Wk_Com=*) that applies to all records in the table. That should enable you to extract all records for the matched clients.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple queries on table mdb/accdb, missing tables & queries Peter J. Veger Mail Merge 1 02-23-2012 10:42 PM
Multiple queries on table Mailmerge with Access queries optiontips.in Mail Merge 2 11-21-2011 03:12 AM
Multiple queries on table Table of contents with multiple coloured headings chaka2487 Word 3 10-17-2011 01:18 PM
Multiple queries on table table spanning multiple pages 'upside down' lj_eco Word Tables 13 07-17-2011 04:39 PM
mail merge queries not displaying donwalt Mail Merge 0 09-05-2010 02:41 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:48 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft