i am having some problem in navigating records...
when i am moving any record next, it moves record by record nect,and also it moves previous,but when i either press last or first, then these both next and previous button do not work..
here is a code.

Private Sub movefirst1_Click()'it is working very fine
Call MyDatacon
Set RS = New ADODB.Recordset
RS.Open "SELECT * From CUSTOMER", con, adOpenStatic, adLockOptimistic
RS.MoveFirst
txtcode1.Text = RS!Customercode
txtshopname = RS!shopname
Call Search
RS.close
con.close
End Sub

Private Sub movelast1_Click() 'it is also working fine
Call MyDatacon
Set RS = New ADODB.Recordset
RS.Open "SELECT * From CUSTOMER", con, adOpenStatic, adLockOptimistic
RS.MoveLast
txtcode1.Text = RS!Customercode
txtshopname = RS!shopname
Call Search
RS.close
con.close
End Sub

Private Sub movenext1_Click()it doesn't work when i am pressing move first
On Error GoTo Err
Call MyDatacon
Set RS = New ADODB.Recordset
RS.Open "SELECT * FROM Customer", con, adOpenStatic, adLockOptimistic
RS.AbsolutePosition = xbookmark
RS.MoveNext
txtcode1.Text = RS!Customercode
txtshopname = RS!shopname
Call Search
xbookmark = xbookmark + 1
RS.close
con.close
 Exit Sub
Err:
'End of file was reached, exit sub
'MsgBox "Last Record"
Exit Sub
End Sub

Private Sub movepre1_Click()'it doesn't work when i am preesing movelast.
On Error GoTo Err
Call MyDatacon
Set RS = New ADODB.Recordset
RS.Open "SELECT * FROM Customer", con, adOpenStatic, adLockOptimistic
RS.AbsolutePosition = xbookmark
RS.MovePrevious
txtcode1.Text = RS!Customercode
txtshopname = RS!shopname
Call Search
xbookmark = xbookmark - 1
RS.close
'If rs.BOF Then
'MsgBox "First Record"
con.close
 Exit Sub
Err:
End Sub

Recommended Answers

All 6 Replies

where xbookmark=1 on formload

I'm not sure what you mean Jaseem. Is the move first and move last not working, but move next and move previous works fine?

No Andre, move last and move first both are working fine...and move next and move previous are also working..but when i am going to move last, and then press move previous, it doesn't moves...and when i am going to move first, move next dosent moves record..
e.g
there are 5 records..
when i am executing form, move next and move previous both works..
on a 2nd record, i thought to go on 5th record,and pressed move last, i reached at 5th record,now i want to move previous,but here move previous doesnt work. same with move next.

I see. You need to work with the recordset's Absolute Position property -

Dim xMark As Integer

xMark = rs.AbsolutePosition

'For Next record use...
rs.Move xMark + 1

'For previous use...
rs.Move xMark - 1

'Just cover error trapping for BOF or EOF scenarios.

If this still does not work for you, post your code so I can see where the problem lies.

Andre, Look at Up, i have posted the code, and what have u told me about absoluteposition, i already have mentioned that..please have a look at Move Next and Previous's Coding.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.