move previous (1 Viewer)

rschultz

Registered User.
Local time
Today, 20:27
Joined
Apr 25, 2001
Messages
96
I need to find a record and move back one record. The code I have listed below works great but sometimes the previous record doesn't have an address in the [Address] field so I need to move back one more record. I've been playing with the code listed below to see if I can say 'if the [Address] field is blank move back one more record but I can't seem to get it to work. Any suggestions?
Dim MyAdj, i As Variant
Dim RS As DAO.Recordset
Set RS = CurrentDb.OpenRecordset("APS Import Test")
Dim STRField As String
'For i = 1 To RS.RecordCount
RS.MoveFirst
For i = 2 To RS.RecordCount
If i = 1 Then
RS.MoveFirst
Else
RS.MoveNext
End If

If (RS.Fields("Adjustments ").Value) <> " " Then
With RS
.Edit
MyAdj = .Fields("Adjustments ").Value
.Update
.MovePrevious
.Edit
.Fields("Adjustments ").Value = MyAdj
.Update
.MoveNext
End With
End If
Next i
 
Try this


If RS.Fields("Adjustments ").Value <> "" Then
With RS
MyAdj = .Fields("Adjustments ").Value

Do While Trim(Nz(.Fields("Address"),"")) <> "" And .BOF = False
.MovePrevious
Loop

.Edit
.Fields("Adjustments ").Value = MyAdj
.Update
.MoveNext
End With
End If
 

Users who are viewing this thread

Back
Top Bottom