Results 1 to 7 of 7
  1. #1
    be_insane is offline Novice
    Windows 7 32bit Access 2002
    Join Date
    Oct 2013
    Posts
    4

    Selcting records by date - But only one booking

    Hi all.

    Been a while since I used access and trying to get my head back round things. Right I have two tables at the moment - one is bookings done by date - linked through to customers via customer ID.



    Now what I am after is a simple query on bookings for bookings before a certain date where a customer has then not made a subsequent booking after that date.

    IE want all customers who only made a booking before 2010 and not any since.

    Can anyone help?

    Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You can use the first query here to get the last booking for each customer.

    http://www.baldyweb.com/LastValue.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    be_insane is offline Novice
    Windows 7 32bit Access 2002
    Join Date
    Oct 2013
    Posts
    4
    Thanks for the reply - but not quite what I'm after...

    right sample data below.

    Client OperatorName Broch wfDepDate wfBookDate
    1 Sunspot Tours Ltd (a) WS 24-Jan-10 11-Jan-10
    2 Transun Holidays (c) WS 26-Jan-10 11-Jan-10
    2 African Pride (c) TM 01-Feb-10 20-Jan-10
    3 Jetset (d) 01-Dec-10 06-Sep-10
    3 Jetset (d) 19-Mar-13 31-Jan-13
    4 Virgin Holidays Limited (d) LH 03-Feb-11 11-Jan-11


    So the client column is the unique client number which relates to a particular client (contact details in a different table).

    So from the above we have four clients, client 1 has only made one booking in 2010, client 2 has made 2 bookings both in 2010, client 3 also 2 bookings one in 2010 the other 2013 and client 4 has done 1 in 2011.

    What I need is to have a query that could find me all customers who booked in 2010 BUT have not made a booking after 2010. So in this case it would return clients 1 and 2 only.

    any help would be appreciated.

    Quote Originally Posted by pbaldy View Post
    You can use the first query here to get the last booking for each customer.

    http://www.baldyweb.com/LastValue.htm

  4. #4
    be_insane is offline Novice
    Windows 7 32bit Access 2002
    Join Date
    Oct 2013
    Posts
    4
    Thanks PBaldy.

    After a bit more thinking I realised I could use this 'last booked' approach to achieve what I needed to by combining it with another query which I define by a booking time range.

    Now - further question - so same situation of multiple bookings for one person - is there an easy way to create new fields showing their total and average spend over all bookings?

    thanks all.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Are you familiar with a totals query? You would group on the person, sum and average the amount field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    be_insane is offline Novice
    Windows 7 32bit Access 2002
    Join Date
    Oct 2013
    Posts
    4
    Hi PBaldy. Thanks for your help - I think I have worked out a way of doing it - similar to the approach for the last booking date.

    As mentioned been a while since I did databases and i'm slowing having to re-learn things!

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No problem. Welcome back!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Booking system form
    By pelicanbuyer in forum Forms
    Replies: 1
    Last Post: 05-11-2013, 08:13 AM
  2. prevent double booking!! help!
    By Jean-Daniel in forum Access
    Replies: 5
    Last Post: 05-16-2012, 06:09 AM
  3. Selcting max value with all duplicate rows
    By HectorH in forum Queries
    Replies: 9
    Last Post: 07-21-2011, 12:17 PM
  4. Appointment Booking Database
    By richie2837 in forum Access
    Replies: 1
    Last Post: 07-16-2011, 01:39 AM
  5. booking in form
    By yoma in forum Forms
    Replies: 1
    Last Post: 07-31-2009, 05:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums