this is my code
Dim Reloc, RelocPrev1, RelocPrev2 As String
Dim Blk, Blk2, Lt, Lt2, PrevDate As String
Dim LotComp, BlockComp As Integer
Dim DB As Database
Dim RS As Recordset
Private Sub SearchBtn_Click()
Reloc = Me.RArea.Value
Set DB = CurrentDb()
Set RS = DB.OpenRecordset(Reloc, dbOpenDynaset)
Blk = RS!Block
Lt = RS!Lot
Blk2 = Me.BlockTxt
Lt2 = Me.LotTxt
BlockComp = StrComp(Blk, Blk2, 1)
LotComp = StrComp(Lt, Lt2, 1)
RS.MoveFirst
Do Until BlockComp = LotComp
RS.MoveNext
Loop
Call RetrieveData
End Sub
RS!Block and RS!Lot works fine, only RS.Movenext and RS.Edit which I tried doesn't work. My table is populated with more than 50 rows. First item in the table can be pulled just fine, I just can't move to the next row with RS.MoveNext
Any ideas to make this work?
And Not RS.EOF
to the loop condition so that it looks like:Do Until BlockComp = LotComp And Not RS.EOF
. There is a nifty debugger built-in that is very useful. You can use that to step through the VBA code and inspect/print variables, if what I've mentioned does not help. – Paul T.