Hi
I am currently trying add variables into my database. I have managed it by storing the data in a table in the backend database. I also have a function to retrieve the data.
This all works, until I try to build a form that updates the data.
The structure of the table is, 3 fields (1. ID, 2.DATA, 3.Description)
I then reference it by the ID number.
When I use the below code to update the DATA in row ID# with a specific piece of data. I get an error message saying "Run-time error '3219': Invalid Operation".
Sub UpdateMyCompany(ID As Integer, NewData As String)
Dim myDb As Database, MySet As DAO.Recordset
Set myDb = CurrentDb()
Set MySet = myDb.OpenRecordset("TBL_MyCompany", dbOpenTable)
MySet.Index = "PrimaryKey"
MySet.Seek "=", ID
MySet.Edit
MySet!Data.Value = NewData
MySet.Update
Debug.Print "UpdateKeyData: Record " & Format(ID, "#") & " changed to " & NewData
MySet.Close
End Sub
This is a new subject to me, so any help is appreciated!
Thanks,
Arron
I am currently trying add variables into my database. I have managed it by storing the data in a table in the backend database. I also have a function to retrieve the data.
This all works, until I try to build a form that updates the data.
The structure of the table is, 3 fields (1. ID, 2.DATA, 3.Description)
I then reference it by the ID number.
When I use the below code to update the DATA in row ID# with a specific piece of data. I get an error message saying "Run-time error '3219': Invalid Operation".
Sub UpdateMyCompany(ID As Integer, NewData As String)
Dim myDb As Database, MySet As DAO.Recordset
Set myDb = CurrentDb()
Set MySet = myDb.OpenRecordset("TBL_MyCompany", dbOpenTable)
MySet.Index = "PrimaryKey"
MySet.Seek "=", ID
MySet.Edit
MySet!Data.Value = NewData
MySet.Update
Debug.Print "UpdateKeyData: Record " & Format(ID, "#") & " changed to " & NewData
MySet.Close
End Sub
This is a new subject to me, so any help is appreciated!
Thanks,
Arron