Hair tearing time -AAAArrrrggg!!!

dwilliams

Registered User.
Local time
Today, 02:35
Joined
Jul 29, 2006
Messages
22
I am trying to create and edit a new record in an existing table,(Transactions). It has 3 records in. When the code below runs, it creates the new record, (Record 4), but updates Record 3 - NOT the new one. The field I want to update is called 'Balence'. Any help apopreciated. I have run this code or similar to update new records previously and it has worked fine.
Any help is greatly appreciated, thank you.


Private Sub Command12_Click()

Dim MyDB As Database
Dim MyRS As Recordset

Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MyRS = MyDB.OpenRecordset("TblTransactions", DB_OPEN_TABLE)

MyRS.AddNew
MyRS.Update
MyRS.MoveLast
MyRS.Edit
MyRS![Balence] = 1000
MyRS.Update

End Sub
 
It's unnecessarily long. Remove these 3 lines:

MyRS.Update
MyRS.MoveLast
MyRS.Edit

and it should work fine. Hopefully you're cleaning up in the real code?
 
It works

Thank you very much for your advice. I am a beginner and it is my aim to write good fast code, but we all gotta start somewhere.

Thanks again.

David
 

Users who are viewing this thread

Back
Top Bottom