Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5987055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:45:35+00:00 2026-05-22T22:45:35+00:00

I am new to Access and am using Access 2007. I am doing a

  • 0

I am new to Access and am using Access 2007.

I am doing a simple query on a database that has a list of customers who visits a workshop.

I want to send out reminders to the customers for their servicing 3 months from the last time they visited. I have created a query to be able to return me the list of customers who has visited 3 months from the current month. For example, if it is May now, 3 months ago would be March (inclusive of May).

However, customers who visited 3 months ago may have visited again 2 months ago. For example, customer A came in March and April. His last visit was in April, and hence, should not appear in the result if I were to run the query in May, as his reminder should only be sent out in June.

My query has taken care of this, however, it is rather slow. It takes some time for it to load in Access. Any help would be appreciated in optimizing it.

The only important field here is Invoice.DebCode which is the customersID in the database. There is another table DEBTOR, which is the table of customers together with their particulars.

I used the INNER JOIN as I need to display the customer(Debtor) address and particulars in the result.

SELECT Invoice.InvNo, Invoice.InvDate, Invoice.DebCode, Debtor.DebName, Debtor.AddL1, Debtor.AddL2, Debtor.AddL3, Invoice.CarNo, Invoice.ChaNo, Invoice.ExcReason
  FROM Debtor 
  JOIN Invoice ON Debtor.DebCode = Invoice.DebCode
 WHERE Year(InvDate) = Year(Now())   
  AND Month(InvDate) = Month(Now()) - 2
  AND Invoice.DebCode NOT IN (SELECT Invoice.DebCode
                                FROM Invoice
                               WHERE Year(InvDate) = Year(Now()) 
  AND (   (Month(InvDate) = Month(Now()) -1) 
       OR (Month(InvDate) = Month(Now())) )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:45:36+00:00Added an answer on May 22, 2026 at 10:45 pm

    What about something like:

    SELECT a.debcode, a.debname, a.debstuff, b.most_recent AS last_over_three_months
    FROM debtor AS a INNER JOIN 
    (
    SELECT debcode, Max(invdate) AS most_recent
    FROM invoice
    GROUP BY debcode
    )
    as b 
    ON a.debcode= b.debcode
    WHERE (month(now()) - Month(most_recent) >2);
    

    You will have to tweak for your stuff, but the idea is a subquery that select the most recent customer visit and then selects from that only the records that meet your month criteria.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I am working on a new application that uses a jet (MS Access) database.
Access 2007 is telling me that my new expression is to complex. It used
I am new to MS Access 2007 and I am creating an application using
Using C, I am trying to create an Access 2007 database file using ODBC
I'm new creating applications using Visual Studio 2010 and Microsoft Access 2007. I already
I am new in creating application using Visual Studio 2010 and Microsoft Access 2007.
I'm using ADO to delete a record in my MS Access 2007 database and
Im using this code to connect to access 2007 database : public void RetrieveData(){
I'm relatively new in using Access. I'm creating a database for questions and answers.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.