Previous row entry (1 Viewer)

racdata

Registered User.
Local time
Today, 18:56
Joined
Oct 30, 2002
Messages
74
I have a dB called logbook
The table have
Date
From
To
KmStart
KmEnd
Length
Etc.
1234 Start 1250 End 16 Length
1250 Start 1350 End 100 Length
In the form where I enter the start km and end km of a trip I want the previous [end km] entered in the next row start km. Without typing the start km again.
Can this be done by access and then calculate after the end km is entered.
Thanks for the help
 

missinglinq

AWF VIP
Local time
Today, 11:56
Joined
Jun 20, 2003
Messages
6,423
If I understand this correctly, Allen's hacks are probably overkill, in this particular situation. Also, I believe all of them are meant for carrying Values forward in a single session, i.e. if you're entering a bunch of Records in one sitting.

If you're closing your Form, between entering Records, and still want the last Value brought forward, this little bit of code will work in that situation as well as in a single-session situation:
Code:
Private Sub Form_Current()
 If Me.NewRecord Then
  Me.KmStart = DMax("KmEnd", "YourTable/QueryName")
 End If
End Sub
You need to, of course, replace YourTable/QueryName with the actual name of the Table or Query that your Form is based on.

If this is a Single-User, free-standing app, i.e. if one user is running it on his machine, it will work fine in the OnCurrent event, as given above. If this were to be used in a Multi-User environment, the code needs to be moved to the Form_BeforeUpdate event.

Linq ;0)>
 

Users who are viewing this thread

Top Bottom