when a certain form is opened the open event runs this code
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM PaymentsMadeForALbaran where saleslink = " & Me.OpenArgs, dbOpenDynaset)
Set Me.Recordset = rs
This is to do with having transaction processing and having the ability to discard changes.
This all works fine.
I want the user to be able to add a new record. This works fine too, but I want to be able to get data from the previous row as well.
I was using a method that basically did a DLookUp on the previou record by assuming that the ID was current ID - 1. I quickly discovered this has inherent problem, i.e. it doesn't work!
So is there any way in getting data from the previous record in the record set for ue in the new record?
I tried adding in this
If Me.Recordset.BOF Then
Beep
MsgBox "You are at the beginning."
DoCmd.GoToRecord , , acFirst
Else
DoCmd.GoToRecord , , acLast
Me.netamount = Me.Recordset.netamount
Me.previousamount = Me.Recordset.paymentamount
end if
but it seems to pick up the data from he 1st record of the recordset.
I also changed
Set rs = db.OpenRecordset("SELECT * FROM PaymentsMadeForALbaran where saleslink = " & Me.OpenArgs, dbOpenDynaset)
to
Set rs = db.OpenRecordset("SELECT * FROM PaymentsMadeForALbaran where saleslink = " & Me.OpenArgs & " ORDER BY PAymentID", dbOpenDynaset)
but no change
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM PaymentsMadeForALbaran where saleslink = " & Me.OpenArgs, dbOpenDynaset)
Set Me.Recordset = rs
This is to do with having transaction processing and having the ability to discard changes.
This all works fine.
I want the user to be able to add a new record. This works fine too, but I want to be able to get data from the previous row as well.
I was using a method that basically did a DLookUp on the previou record by assuming that the ID was current ID - 1. I quickly discovered this has inherent problem, i.e. it doesn't work!
So is there any way in getting data from the previous record in the record set for ue in the new record?
I tried adding in this
If Me.Recordset.BOF Then
Beep
MsgBox "You are at the beginning."
DoCmd.GoToRecord , , acFirst
Else
DoCmd.GoToRecord , , acLast
Me.netamount = Me.Recordset.netamount
Me.previousamount = Me.Recordset.paymentamount
end if
but it seems to pick up the data from he 1st record of the recordset.
I also changed
Set rs = db.OpenRecordset("SELECT * FROM PaymentsMadeForALbaran where saleslink = " & Me.OpenArgs, dbOpenDynaset)
to
Set rs = db.OpenRecordset("SELECT * FROM PaymentsMadeForALbaran where saleslink = " & Me.OpenArgs & " ORDER BY PAymentID", dbOpenDynaset)
but no change
Last edited: