troubleshooting Question

Query to update fields with data from table rows above with the same dwelling type

Avatar of AndyC1000
AndyC1000 asked on
Microsoft Access
8 Comments2 Solutions47 ViewsLast Modified:
Dear all,

I posted a similar question a while ago see the link below.  The vb code populates the record where all values are 0 with the populated record above.  The issue is now I need to check the dwelling type of the record with all 0's and populate with the record above with the same dwelling type.  I'm unsure of how to make this change.  I'm happy with the vb solution although if there is another approach I would also be interested.

I've created two tables below with the original dataset and the new results I'm trying to achieve.  The dwelling types aren't grouped so the code might need to search many records above before it finds the correct dwelling type.   The  HCFMDCode is updated to B when a change is made.

The original table looks like this:

ID      DwellingType Couple      Family        Other            HCFMDCode
1           House            0.433          0.567           0                    A
2            House            0.223          0.388           0.388             A
3           House            0                  0                  0                    A
4           House            0                  0                  0                    A
5            Unit                0.355          0.332           0.332             A
6            Unit                0                  0                  0                    A

The final results should produce:
ID      DwellingType Couple      Family        Other            HCFMDCode
1           House            0.433          0.567           0                    A
2            House            0.223          0.388           0.388             A
3           House            0.223          0.388           0.388             B
4           House            0.223          0.388           0.388             B
5            Unit                0.355          0.332           0.332             B
6            Unit               0.355          0.332           0.332              B

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 2 Answers and 8 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 2 Answers and 8 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004