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 8823919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:28:42+00:00 2026-06-14T06:28:42+00:00

This is my first question, please be kind. I am writing a macro in

  • 0

This is my first question, please be kind. I am writing a macro in access and I want a series of reports to run one after another. the problem is all report have a date range that needs to be entered. Some are for the previous week some are for the previous month.

Is there a way in VBA or the macro creator to automatically calculate a date range for the previous month or week and populate the field to fully automate the process without manually entering the date range each time.

I am a new to VBA. Any help would be great, just point me in the right direction. Have a good day.

  • 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-06-14T06:28:43+00:00Added an answer on June 14, 2026 at 6:28 am

    This query is created using the query design window in MS Access and then cut from SQL view. It will show records for last week, where ww is week number, in table1

    SELECT Table1.AKey, Table1.atext, Table1.ADate, 
           Format([ADate],"ww") AS Week, Month([ADate]) AS [Month], 
           Year([ADate]) AS [Year]
    FROM Table1
    WHERE (((Format([ADate],"ww"))=Format(Date(),"ww")-1)
    AND ((Year([ADate]))=Year(Date())));
    

    You will notice that one column is called Month. You can use this to set a previous month in a similar way to setting the previous week. For example, both last week and last month:

    SELECT Table1.AKey, Table1.atext, Table1.ADate, 
           Format([ADate],"ww") AS Week, Month([ADate]) AS [Month], 
           Year([ADate]) AS [Year]
    FROM Table1
    WHERE (((Format([ADate],"ww"))=Format(Date(),"ww")-1) 
    AND ((Year([ADate]))=Year(Date()))) 
    OR (((Month([ADate]))=Month(Date())-1) 
    AND ((Year([ADate]))=Year(Date())));
    

    The SQL could be written much more neatly, but you may as well start with the query design window.

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

Sidebar

Related Questions

This is my first question on Stack Overflow. Please be kind on my mistakes.
Full disclosure...this is my first SO question. Please be kind if I leave anything
This is my first question, so please be gentle. I'm trying out Apache Camel
This is my first post on stackoverflow, so please excuse me if my question
This might seem to be a silly question at first, but please read on.
Please read Update1 first! This is SSIS specific question. I have the following tasks:
First, I know this is kind of common question, but I could not find
My first question so please be kind. I am having problems with my installer
This is my first time posting here, so please be kind ;-) EDIT My
this is my first question in here, and I would like to ask if

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.