Find Record in Access Using Excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
Would someone be able to provide the code to find a record in an Access
table using data in excel.

ie have an order number in excel and I want to find the record in the Access
database for the order number so I can update the record for that order in
Access table.

thanks
Noemi
 
Here is some code you can modify to fit your specific database, table,
etc. You need to check Microsoft DAO x.x Object Library using the menu
Tools | References.

Sub ModifyAccessRecord()
Dim db As Database, rs As Recordset
Set db = OpenDatabase("C:\FolderName\DataBaseName.mdb")
Set rs = db.OpenRecordset("TableName", dbOpenTable)
Do
If rs.Fields("FieldName1") = "something" Then
rs.Edit
rs.Fields("FieldName2") = "something else"
rs.Update ' stores the new record
End If
rs.MoveNext
Loop Until rs.EOF
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub

HTH,
Merjet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top