Hi,
I have a table and I want to add a new record based on the last record in the recordset by doing this
Code:
Private Sub Comando26_Click()
Dim dbn As Database
Dim rstn As Recordset
Dim lcn As IntegerDim
lfi As DateDim
lff As Date
Set dbn = CurrentDb
Set rstn = dbn.OpenRecordset("tabNomina", dbOpenTable)
rstn.MoveLast
lcn = rstn.Fields("codnom")
lfi= rstn.fields("fecini")
lff=rstn.fields("fecfin")
lcn=lcn+1
lfi=lff+1
lff=lff+7
rstn.AddNew
rstn.Fields("codnom")=lcnrstn.fields("fecini")=lfi
rstn.fields("fecfin")=lff
End Sub
The problem is that the recorset is saved as if the first record in the table was the last, so the second record in the table becomes the first in the recordset.
How can I solve this problem? I used rstn.MoveLast and then rstn.MovePrevious that shows the real last record but i think that is not a good solution.