Access update Query

I have this access database that has a table with some records.  What i want to do is to have a update query that will take the Item Name column and Description column have them updated to what is shown in the image below.  Any ideas?  thank you

Before-and-After.jpgTestDatabase.accdb
gsilouisvilleicAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
the easiest way to do this is:
- open the table
- select all records, copy
- open an excel file and paste
- use the excel capability of copying the cell downward
- save the excel file
- from Access, import the created excel file

otherwise, you'll use vba codes to update the records
0
gsilouisvilleicAuthor Commented:
i need it in code because i will have hundreds of different records that i have to copy and paste each time.  i just gave a small sample of it and i will get new information each week.
0
Rey Obrero (Capricorn1)Commented:
where did these records came from? are these a result of importing files?
0
Rey Obrero (Capricorn1)Commented:
first, you have to add an AutoNumber (ID) field to your tables

run this codes
Sub UpdateTable()
Dim rs As DAO.Recordset, strItemName As String, strPrevItem As String, strDesc As String, strPrevDesc As String
Set rs = CurrentDb.OpenRecordset("select * from [T_Test Table] Order by ID")
Do Until rs.EOF
    strItemName = Nz(rs![Item Name], "")
    strDesc = Nz(rs!Description, "")
    If strItemName & "" <> "" Then
        If strPrevItem <> strItemName Then
           strPrevItem = strItemName
           strPrevDesc = strDesc
           Else
        End If
        
        Else
            rs.Edit
            rs![Item Name] = strPrevItem
            rs!Description = strPrevDesc
            rs.Update
    End If

rs.MoveNext
Loop

rs.Close
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gsilouisvilleicAuthor Commented:
You are the best!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.