Results 1 to 6 of 6
  1. #1
    kevinnice is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    10

    sql . need a genius


    I have a table for holidays at houses.
    Each record has a house_ref,start_date_of_holiday, end_date_of_holiday etc.
    (I have another table (houses) which is related by house_ref.)

    I want to have a form which shows which houses are available for a particular period.
    ie user specifies start date and end date of query, asking the question: Which houses are available for rent in that period?

    To me it's just a head-shag...

    Any genius can help me?

    Rodney

  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
    Does this get you started?

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

  3. #3
    kevinnice is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    10
    Thanks baldy, it's a partial answer. But I have 1000 booking records, for a variety of 100 houses in my db. So it's no not like saying "is a particular house available from1st June to 13th June'" It's saying "which houses (of the 100) are available in that period".

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    With that technique you find which houses are booked. Using the Unmatched query wizard with the houses table against that query leaves you with the available houses.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    kevinnice is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    10
    Thanks again. I can get the logically "counter-intuitive" query. So if I go through my 100 bookings, using this logic, I can determine which bookings fall INSIDE the period, rendering the houses they refer to NOT AVAILABLE.

    It's the bringing it togetehr part that i have trouble with: Say I start with my table of 100 villas - do I just use that example to disqualify them? And, if so, how do I code that?

    Have to say - thanks again.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Like I said, use the Unmatched query wizard. It will ask for two sources, and basically return all the items that are in the first source that aren't in the second. In your case, the first source is your table of 100 houses, the second is the query from above.

    Edit: The wizard creates what's often called a "frustrated left join"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

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