0

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
2
Contributors
6
Replies
13
Views
5 Years
Discussion Span
Last Post by Jaseem Ahmed
0

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?

0

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.

0

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.
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.