Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can anyone help with this bit of code please? 1

Status
Not open for further replies.

BigKingDave

Programmer
Jul 29, 2006
3
GB
I am trying to create and edit a new record in an existing table called 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.

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
 
HELLO.

This is ASP.NET forum with VB.NET or C#.

As i see from:
1. 'SET' keyword
2. '_Click' (how event's are handled)

I assume that this a vb6 question (maybe vba).

PLEASE post in forum222 if this is a vb6 question.

____________
PS: Try removing the 'MyRS.MoveLast' and see what happens
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top