By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

how to moveprevious and movenext

P: 1
Hi,

I have developed a small application in vb6 and access Actually i want to move through recordset i.e movenext and move previous but it always go to end of record.I have stuck up in this and not able to solve this problem.Please help me.Thanks in advance. I am using access database and following is my code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdnext_Click()
  2. On Error Resume Next
  3.  
  4.     Set con = New ADODB.Connection
  5.     Set rs = New ADODB.Recordset
  6.     rs.Open "cust1", strcn
  7.     While Not rs.EOF
  8.         rs.MoveNext
  9.         filldata
  10.     Wend
  11. End Sub
  12.  
  13.  
  14. Private Sub cmdprevious_Click()
  15.     rs.Close
  16.     Set rs = New ADODB.Recordset
  17.     rs.CursorType = adOpenStatic
  18.     rs.CursorLocation = adUseClient
  19.     rs.Open "cust1", strcn, adOpenStatic, adLockReadOnly, adCmdTable
  20.     MsgBox rs.RecordCount
  21.     rs.MovePrevious
  22.  
  23.     If Not rs.BOF = True Then
  24.         rs.MoveFirst
  25.         MsgBox ("This is first record")
  26.  
  27.     End If
  28. filldata
  29. end sub
  30.  
  31. Sub filldata()
  32.     txtcode.Text = rs.Fields!code
  33.     txtfullname.Text = rs.Fields!fullname
  34.     cmbstatus.Text = rs.Fields!Status
  35.     txtname.Text = rs.Fields!Name
  36.     txtpobox.Text = rs.Fields!pobox
  37.     txttel.Text = rs.Fields!offtel
  38. End Sub
Apr 15 '07 #1
Share this Question
Share on Google+
1 Reply


iburyak
Expert 100+
P: 1,017
Change adOpenStatic to adOpenDynamic

Good Luck.
Apr 15 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.