I got a problem.
I want to update an existing record in table in Access Database using VBA in EXCEL.
sqlik = "UPDATE query which works in access" Set ZAP_QUERY2 = baza.CreateQueryDef("", sqlik) With ZAP_QUERY2 ![abc] = Edit_Form.abc.Text ![bcd] = Edit_Form.bcd.Text ![cde] = Edit_Form.cde.Text End With
When I used sqlik = “SELECT query which works in access” it didn’t make any changes. But with sqlik = “UPDATE query which works in access” it says that “Cannot find any object in this collection”
Thanks for your help
A solution using DAO:
... dim db as DAO.Database, rec as Dao.Recordset dim strSQL as String Set db = OpenDatabase("c:\DatabaseFolder\YourDatabase.accdb") strSQL = "SELECT * FROM yourTable WHERE yourField=1" Set rec = db.OpenRecordset(strSQL, dbOpenDynaset, dbEditAdd) With rec .MoveFirst ![aField] = Edit_Form.abc.Text .Update End With rec.Close db.Close ...
Hope this helps you