edit record "code"

sasolini

Registered User.
Local time
Today, 20:40
Joined
Dec 27, 2004
Messages
61
Can someone pls tell me how can i edit a specific data in table..The problem is that the code that i have does not edit data of the specific ID but allways the first data in my table. The second problem is that i get an errorr after editing with this code askin me if a want to copy my data to clipboard, save or descard data, and i dont want that. All I want is that my data of the specific ID would change...

Private Sub UZ_AfterUpdate()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblUZ")
rs.Edit
rs!DatumVnosa = Now
rs!Uporabnik = CurrentUser
rs.Update
rs.Close
db.Close
End Sub


Regards, S
 
sasolini said:
Can someone pls tell me how can i edit a specific data in table.
Private Sub UZ_AfterUpdate()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblUZ")
rs.Edit
rs!DatumVnosa = Now
rs!Uporabnik = CurrentUser
rs.Update
rs.Close
db.Close
End Sub[/code]

Firstly, you need to loop through the records until you get to the one you want. Or filter the recordset. Since you are only editing a record's value, then why not just use an UPDATE QUERY?

The reason you are asked about saving changes to clipboard or whatever it is, is because the recordset you have opened is, most likely, the same one that is opened/bound on the current form. Different changes to instances of the same recordset will require that only one can be updated.
 

Users who are viewing this thread

Back
Top Bottom