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