Results 1 to 5 of 5
  1. #1
    madwildfire is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    2

    How to find Voids in data?

    Hi All,

    I'm creating a database for managing the Leases of a number of different properties, these leases typically run for six months.

    As such I have three tables : Tenants, Properties and Leases.

    What I'm struggling to create is a query or vba script that can, for a given start and end date, tally the number of days that a property has not been leased.

    Could anyone point me in the right direction on what I could research to accomplish this?


    Many thanks,



    Will

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe the datediff() function?

    Code:
    dim strgiven_start as string
    dim strend_date as string
    dim intAnswer as integer
    intAnswer = DateDiff("d", strgiven_start, strend_date)
    msgbox intAnswer

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Yes or put it in a query:

    Select *, DateDiff("d", strgiven_start, strend_date) as Days from tLEASES

  4. #4
    madwildfire is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    2
    Thank you both for your answers, your methods absolutely allow calculating the period of the lease.

    I did not provide a great deal of detail in my opening post. What I'd like to tally is the number of days for which a lease record does not exist, i.e. the period the property does not have a corresponding Lease record.

    How can we total this 'missing' data?

    Edit_
    Looking into how I can go about counting from the end (EndDate field) of one record and the start (StartDate field) of the next record, but within a specified date range.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    If it was me I would do the whole thing in VBA and build the results to a temp table. Using DAO, I would grab the first unit and its End Date. I would go through that units history using findfirst in a second DAO recordset, sorting start dates ascending. I would calc the date diff and add it to a variable of integer type. At the end of looping through the first unit's history I would write the value of the integer and the corresponding unit ID to my temp table.

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

Similar Threads

  1. Find data in a combo box
    By TheHarleygirl2005 in forum Forms
    Replies: 4
    Last Post: 01-04-2013, 01:01 PM
  2. importing data- find new data
    By cengineer in forum Import/Export Data
    Replies: 1
    Last Post: 12-10-2009, 08:56 AM
  3. find specific data
    By hoachen in forum Queries
    Replies: 3
    Last Post: 08-19-2009, 08:54 AM
  4. Find out changed data
    By Papote in forum Programming
    Replies: 1
    Last Post: 04-27-2009, 08:19 PM
  5. Find data, load data, and save as a new record
    By hawzmolly in forum Access
    Replies: 0
    Last Post: 10-05-2008, 03:18 PM

Tags for this Thread

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