MoveNext

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kitt
    New Member
    • Jul 2006
    • 5

    MoveNext

    Hi everyone,
    I am kind of new in VB programming. I am using SQL as my database. The fields are 1.serial 2.datestring 3.Job 4.Achievement 5.Remarks
    I wanted to go from one record to the next but I just couldn't get to it. I tried using rs.MoveNext, but it didn't work. I think I am unable to get to some things.

    Your help would be highly appreciated.
    Kitt
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Hi Kitt,

    post your current code segment and we will try to debug the code.. it's kind of impossible to guide you without seeing your code.. good luck my fren.. :)

    Comment

    • kitt
      New Member
      • Jul 2006
      • 5

      #3
      Following is my code. I look forward for your help.

      Dim con As ADODB.Connectio n
      Dim rs As ADODB.Recordset

      Private Sub cmdNext_Click()
      Set con = New ADODB.Connectio n
      Set rs = New ADODB.Recordset
      rs.Open
      rs.MoveNext
      End Sub


      Private Sub CmdSave_Click()
      Dim save As String
      Set rs = New ADODB.Recordset
      save = "insert into Evaluation values('" & serial.Text & "', '" & DateString.Text & "','" & Job.Text & "', '" & Achievement.Tex t & "', '" & Remarks.Text & "')"
      rs.Open save, con, adOpenDynamic, adLockOptimisti c
      serial.Text = ""
      DateString.Text = ""
      Job.Text = ""
      Achievement.Tex t = ""
      Remarks.Text = ""
      End Sub


      Private Sub CmdSearch_Click ()
      Dim search As String
      Set rs = New ADODB.Recordset
      search = "select * from Evaluation where SlNo = '" & serial.Text & "' or Date = '" & DateString.Text & "' or JobResponsibili ties = '" & Job.Text & "' or Achievement = '" & Achievement.Tex t & "'"
      rs.Open search, con, adLockOptimisti c, adOpenDynamic
      serial.Text = rs!SlNo
      DateString.Text = rs!Date
      Job.Text = rs!JobResponsib ilities
      Achievement.Tex t = rs!Achievement
      Remarks.Text = rs!Remarks
      End Sub

      Private Sub Form_Load()
      Dim constr As String
      Set con = New ADODB.Connectio n
      constr = " Provider=SQLOLE DB.1;Persist Security Info=False;User ID=sa;PWD=sa;In itial Catalog=Library ;Data Source=PENJOR"
      con.Open constr
      End Sub

      Comment

      • sashi
        Recognized Expert Top Contributor
        • Jun 2006
        • 1749

        #4
        Hi Kitt,

        i have made some changes to your Sub cmdNext.. pls take note..

        Code:
        Private Sub cmdNext_Click()
        Set con = New ADODB.Connection
        Set rs = New ADODB.Recordset
        rs.Open
          While Not rs.EOF   
            rs.MoveNext
          Wend
        End Sub

        Comment

        • kitt
          New Member
          • Jul 2006
          • 5

          #5
          I tried the code you suggested but I get the following error:
          Run-time error '3709'
          The connection cannot be used to perform this operation. It is either closed or invalid in this context.

          I look forward for your help again.

          Comment

          • sashi
            Recognized Expert Top Contributor
            • Jun 2006
            • 1749

            #6
            Hi Kitt,

            there is nothing wrong in the code segment.. i have found the reason for the error message.. check it out.

            "Run-Time Error '3709'" error message when you enter a large amount of text in a Memo field that contains an index

            exactly when and where does this error occur? i assume it's when you tried saving record.. rite?? check your coding.. good luck my fren.. :)

            Comment

            • kitt
              New Member
              • Jul 2006
              • 5

              #7
              Dear Sasi,
              I am sorry for bothering you time and again. But then, I really need your help and I am grateful that you do help. The error occurs when I click the 'next' button. I can save the record but I cannot go to the next record.

              The error occurs on 'rs.open'.

              Kitt

              Comment

              Working...