Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Value of Last Updated Record

Status
Not open for further replies.

Bonediggler1

Technical User
Jul 2, 2008
156
US
Hi-

I have a table with 3 fields. Field1 will have a value of either 2 or 3. Field2 will have an integer value. Field3 is blank.

I am trying to write code that will loop through the table, and update Field3 based on Field1. Simply put, if Field1 = 2, Field3 equals a parsing of the values in Field2. If Field1 = 3, Field3 should equal the most recent value inputted in Field3 (which would be the value inputted the last time Field1 = 2).

I think the code I have is close (I know the LastUpdated property is wrong). I just don't know how to reference the most recent value of Field3.

With rst
Do Until .EOF
If !Field1 = 2 Then
.Edit
![Field3] = Right(!Field2, 6) & Left(!Field2, 2)
.Update
.MoveNext
ElseIf !Field1 = 3 Then
.Edit
![Field3] = .LastUpdated
.Update
.MoveNext
End If
Loop
End With

Thank you!!
 
As you don't have any DateTime field in your table how do you know which record is the "last updated" ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you for looking into this PHV. Sometimes just writing my question to TekTips brings out the solution automatically:

With rst
Do Until .EOF
If !Field1 = 2 Then
.Edit
![Field3] = Right(!Field2, 6) & Left(!Field2, 2)
x = Right(!Field2, 6) & Left(!Field2, 2)
.Update
.MoveNext
ElseIf !Field1 = 3 Then
.Edit
![Field3] = x
.Update
.MoveNext
End If
Loop
End With

Thanks again!!
 
I still don't understand why you're sure that the recordset is properly sorted ...
 
It is based on a customer file that always comes sorted like this. We don't change anything on import.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top