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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:43:59+00:00 2026-05-22T20:43:59+00:00

I have an MS Access 2007 database that I need to create an update

  • 0

I have an MS Access 2007 database that I need to create an update for. The table I am trying to update looks like this:

 CarID  WeekOf          NumDataPoints   NumWksZeroPoints
 3AA    May-14-2011     23              0
 7BB    May-14-2011     9               0

 3AA    May-21-2011     35              0
 7BB    May-21-2011     0               1

 3AA    May-28-2011     24  
 7BB    May-28-2011     0   

I am processing the latest recordset of May-28-2011 and the gist is to update each car with the number of weeks its had no data points. I do this by checking the current week number of points and if it does have some points then the #WeeksZeroPoints gets set to zero, and if the current number of points is zero then i take the prior weeks count and increment by one. For my last week I would have input

  0
  2

So I have tried something like

UPDATE tblCars 
SET NumWksZeroPoints = IIF(NumDataPoints<>0, 0, (SELECT MAX(NumWksZeroPoints) AS wzp 
                                                 FROM tblCars AS f 
                                                 WHERE f.CarID=tblCars.CarID AND 
                                                       f.WeekEnding=#5/21/2011#) + 1
                       )
WHERE WeekOf=#5/28/2011#;

Unfortunately this doesn’t work like I thought it would. I think I have the concept down and most of the SQL, I just cant seem to make it work. This is against MS Access so some of the other tricks I know just don’t work. Any help appreciated.

  • 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-22T20:44:00+00:00Added an answer on May 22, 2026 at 8:44 pm

    Using your sample data I ran the following

    UPDATE tblcar AS c 
           INNER JOIN tblcar AS previous 
             ON c.carid = previous.carid 
    SET    c.numwkszeropoints = Iif([previous].[NumWksZeroPoints] = 0, 0, 
                                       [previous].[NumWksZeroPoints] + 1) 
    WHERE c.weekof =#5/28/2011 # 
             AND previous.weekof =#5/21/2011#;
    

    The table afterwards looked like this

    CarID WeekOf     NumDataPoints NumWksZeroPoints
    ----- ---------- ------------- -----------------
    3AA   05/14/2011 23            0
    7BB   05/14/2011 9             0
    3AA   05/21/2011 35            0
    7BB   05/21/2011 0             1
    3AA   05/28/2011 24            0
    7BB   05/28/2011 0             2
    

    Basically the query does a self join back to the previous week, and the update the current week to the previous week’s value + 1 if its not zero.

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

Sidebar

Related Questions

I have an access 2007 Database that outputs a report in excel format, the
I have an Access 2007 database that works asynchronously with a MAS200 database. Due
I have a table in an Access 2007 database. All fields are of type
I have built a MS Access 2007 application that can create reports files in
I have a legacy MS Access 2007 table that contains 52 fields (1 field
I have a site that uses classic ASP and a database in Access 2007
I'm trying to make a small VBScript that compacts a MS Access 2007 database
I have an Access database in source control on TFS that I need to
I have inherited an Access 2007 database that has been split so the tables
When a user start an Access 2007 database that have macros and vba, a

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.