Prev Form Record Value

patrickglass

Engineering Student
Local time
Yesterday, 23:09
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
 
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
 
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
 
Thanks a lot for the reply it works great. bye for now. Patrick Glass
 
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.
 
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

Back
Top Bottom