Don Quixote
New Member
- Joined
- Feb 2, 2025
- Messages
- 6
- Office Version
- 2021
- Platform
- Windows
I have an excel userform where I can search for and create new database entries in an ms access table.
But when I try to edit existing entries it gives me an error that the object doesn't support this action.
here is my code so far:
I would use the sql query to find a matching value of the one in txtBestelnummer textbox, and then edit the other fields in that row.
But when I try to edit existing entries it gives me an error that the object doesn't support this action.
here is my code so far:
VBA Code:
Private Sub EditButton_Click()
Dim con As Object
Dim rs As Object
Set con = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Dennis\Documents\Blending & Filling\Basis Olie Lossing\Base Oils.accdb;"
'Open Db connection
con.Open
Set rs.ActiveConnection = con
rs.Open "Select * from [Planning] where [Bestelbon] = " & UserForm1.txtBestelbon.Text & ""
'rs.Open "[Planning]", con, 1, 3, 2
'rs.CursorLocation = adUseClient
'rs.CursorType = adOpenStatic
'rs.LockType = adLockBatchOptimistic
rs.Edit
rs.Fields("Productnaam") = UserForm1.txtProduct.Value
rs.Fields("Transporteur") = UserForm1.txtTransporteur.Value
'rs!Productnaam = UserForm1.txtProduct.Value
'rs!Transporteur = UserForm1.txtTransporteur.Value
rs.Update
rs.Close
Set rs = Nothing
con.Close
Set con = Nothing
End Sub
I would use the sql query to find a matching value of the one in txtBestelnummer textbox, and then edit the other fields in that row.