Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2009
    Posts
    4

    contracts query

    Hi
    I am trying to write a query that with display monthly income for a desired month. The problem is that it only shows the contracts that have started and ended in that month and not ongoing contract payments, that have either started in earlier months or have ended in later months.
    Below is my current attempt.

    Thanks in advance

    SELECT Customer.CustomerNo, Customer.Forename, Customer.Surname, Contracts.ContractNo, Contracts.AddressOfWork, Contracts.MonthlyCost, Gardener.GardenerNo, Gardener.Forename, Gardener.Surname


    FROM Customer, Gardener, Contracts
    WHERE Customer.CustomerNo=Contracts.CustomerNo And Gardener.GardenerNo=Contracts.GardenerNo And Contracts.StartDate And Format([StartDate],"mm/yyyy")=[Enter Month/Year];

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I don't think you did a Cut 'N Paste of the SQL because it should have thrown an error as written. How do you know what are ongoing contract payments for any given date?

  3. #3
    Join Date
    Feb 2009
    Posts
    4
    Quote Originally Posted by RuralGuy View Post
    I don't think you did a Cut 'N Paste of the SQL because it should have thrown an error as written. How do you know what are ongoing contract payments for any given date?
    Once the contract starts it runs every month with the same amount until the end date.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    As a test, try something like:
    And Format([Contracts.StartDate],"mm/yyyy") <= [Enter mm/yyyy]
    And Format([Contracts.EndDate],"mm/yyyy") > [Enter mm/yyyy] ;

    ...it will ask for the date twice.

  5. #5
    Join Date
    Feb 2009
    Posts
    4
    Quote Originally Posted by RuralGuy View Post
    As a test, try something like:
    And Format([Contracts.StartDate],"mm/yyyy") <= [Enter mm/yyyy]
    And Format([Contracts.EndDate],"mm/yyyy") > [Enter mm/yyyy] ;

    ...it will ask for the date twice.
    I tried that. But it only asked for the date once? I have attached the database file so it might be clearer what the problem is. Thanks for your help.

  6. #6
    Join Date
    Feb 2009
    Posts
    4
    Quote Originally Posted by ntd1 View Post
    I tried that. But it only asked for the date once? I have attached the database file so it might be clearer what the problem is. Thanks for your help.
    That was the wrong file. Try this one

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