MoveLast doesn't move last...?

dwilliams

Registered User.
Local time
Today, 21:04
Joined
Jul 29, 2006
Messages
22
Hi - I am trying to open a recordset, move to last record, put a value in a variable for further use.

When I use the MoveLast method it doesnt work. It goes to the the 3rd record from the end and gets that value.

I have tried deleting the primary key field and entering a new one but to no avail - what gives here?? I am missing something.

Help much appreciated - thank you

David



Private Sub Command12_Click()

Dim MyDB As Database
Dim MyRS As Recordset
Dim MyBal As Currency

MyBal = 0

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

MyRS.MoveLast
MyBal = MyRS![Balence]
If Forms!FrmTransaction!Credit > 0 Then
MyBal = MyBal + Forms!FrmTransaction!Credit
Else
MyBal = MyBal - Forms!FrmTransaction!Debit
End If

MyRS.AddNew
MyRS![Balence] = MyBal
MyRS![Credit] = [Forms]![FrmTransaction]![Credit]
MyRS![Debit] = [Forms]![FrmTransaction]![Debit]
MyRS![Transaction Date] = [Forms]![FrmTransaction]![Date]
MyRS![Category] = [Forms]![FrmTransaction]![Category]
MyRS.Update
MyRS.Close
End Sub
 
A table is in no particular order. You would need to use a query to have the records presented in some particular order with an OrderBy clause.
 
Got it

RuralGuy said:
A table is in no particular order. You would need to use a query to have the records presented in some particular order with an OrderBy clause.


Thanks very much, works great now. I appreciate you taking the time to answer.
David
 

Users who are viewing this thread

Back
Top Bottom