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!

I know I am missing something simple - but HELP! 1

Status
Not open for further replies.

BigKingDave

Programmer
Jul 29, 2006
3
GB
I want to create a new record in an existing table 'Transactions', and add a value to the field 'Balence'. 'Balence' is a Currency field. Lets say table has three recods in to start with.

When I run the following code, it creates the new record,(Record 4), but puts the value in Record 3. This indicates that the MoveLast method is not working.

Any help would be greatly appreciated.


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
 
Not sure what are you doing. But how about this?
Code:
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![Balence] = 1000
    MyRS.Update

End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Thank you - works a treat. Obviously trying to overcomplicate things.

Thanks again

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top