Discussion Locked

Edit an Access Database from Excel using DAO

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Can anyone help me edit the following code so that I can use an excel row to edit an access database. The code is to be put in a Macro and used via command button on excel worksheet.
Dim dbMyDB As Database
Set dbMyDB = OpenDatabase("C:\Pro.mdb")
Dim rsMyRS As Recordset
Set rsMyRS = dbMyDB.OpenRecordset("Customers", dbOpenDynaset)

rsMyRS.Edit
rsMyRS!Name = Range(10, 1)' here is the prob
rsMyRS.Update

2 replies

by bschaettle

The code you posted is trying to put a range of cells into the "Name" field of the current record. It should look more like this:

rsMyRS!Name = Range("A1").Value

by ninedemo

When I changed the code as per answer below the results where interesting. However only the first record of the Feild in database was edited. How can I modify the code to edit a whole Feild in an access table. Remember that this is supposed to be a macro placed in excel!

This discussion is closed to new replies.