Prev Form Record Value (1 Viewer)

patrickglass

Engineering Student
Local time
Today, 10:48
Joined
May 10, 2006
Messages
10
Hello, i have been having some problems with my database app. i have a form where the user enters in data name and shift. for multiple records in a row the date and shift would be the same. what i plan to do is have a on update event of the name control that would fill in the other two fields but not if they are done allready.

Basically i know how to do all except retriving the value of the prev record. all are index based so i just need to refer to entry - 1. but i am not sure on how i can do that. i hvae read about dlookup but i dont think thats what i need and well as PrevRecVal, but i dont know how to use that one.

If someone could point me to a link that would help or just a short code peice that would be much appreciated. Thanks for the time. Patrick
 

ansentry

Access amateur
Local time
Tomorrow, 03:48
Joined
Jun 1, 2003
Messages
995
Will it ALWAYS be the previous record?
 

patrickglass

Engineering Student
Local time
Today, 10:48
Joined
May 10, 2006
Messages
10
yes it will always be the previous record. i DO NOT want the newest date record. this is because we do not input in a logical method as we get the data day by day but not of consecutve days. Patrick
 

ansentry

Access amateur
Local time
Tomorrow, 03:48
Joined
Jun 1, 2003
Messages
995
Put this code in the OnCurrent Event of your form.
Change the blue name to suit.


Code:
 Dim rs As Object
    Set rs = Me.Recordset.Clone
    
    If rs.EOF Or Not Me.NewRecord Then
        ' don't do anything if there's no records or it is not a new record
    Else
        With rs
            
            .MoveLast
                       
            Me![[COLOR="Blue"]txtVehicleMake[/COLOR]] = .Fields("[COLOR="Blue"]VehicleMake[/COLOR]")
            Me![[COLOR="Blue"]txtVehicleType[/COLOR]] = .Fields("[COLOR="Blue"]VehicleType[/COLOR]")
          
        End With

    End If
 

patrickglass

Engineering Student
Local time
Today, 10:48
Joined
May 10, 2006
Messages
10
Thanks a lot for the reply it works great. bye for now. Patrick Glass
 

popeye

Work smarter, not harder.
Local time
Today, 10:48
Joined
Aug 23, 2004
Messages
75
ansentry said:
Put this code in the OnCurrent Event of your form.
Change the blue name to suit.


Code:
 Dim rs As Object
    Set rs = Me.Recordset.Clone
    
    If rs.EOF Or Not Me.NewRecord Then
        ' don't do anything if there's no records or it is not a new record
    Else
        With rs
            
            .MoveLast
                       
            Me![[COLOR="Blue"]txtVehicleMake[/COLOR]] = .Fields("[COLOR="Blue"]VehicleMake[/COLOR]")
            Me![[COLOR="Blue"]txtVehicleType[/COLOR]] = .Fields("[COLOR="Blue"]VehicleType[/COLOR]")
          
        End With

    End If

I couldnt have finished my project without the use of this post... I found it extremely useful so Thanx.
 

ansentry

Access amateur
Local time
Tomorrow, 03:48
Joined
Jun 1, 2003
Messages
995
popeye said:
I couldnt have finished my project without the use of this post... I found it extremely useful so Thanx.

Glad it helped you, the code is not all mine I picked it up somewhere.
 

Users who are viewing this thread

Top Bottom