Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Display all records one by one by using rst.movenext  (Read 2958 times)

0 Members and 1 Guest are viewing this topic.

talorababu

    Topic Starter


    Rookie

    Display all records one by one by using rst.movenext
    « on: May 23, 2009, 08:02:19 PM »
    Dear Sir

    I have used below coding to display specific record from the database.
    The problem is, when I click on command button, it is displaying only one record from the database. Though there are other records. I have tried a lot, please see my coding in below:

    Dim rst As New ADODB.Recordset

    Private Sub cmdshow_Click()
    frmpurchaseqty.Visible = False
    SSTab1.Visible = True
    DBconnect
    If rst.State = adStateOpen Then rst.Close
    rst.Open "tblpurchasesupplyqty", cnt, adOpenDynamic, adLockOptimistic
    If Not rst.EOF Then rst.MoveNext
    If cmbsupplier.Text = rst.Fields(5) And cmbitemref.Text = rst.Fields(6) And DTPicker1.Value = rst.Fields(3) Then
    With rst
        frmpurchaseqty.cmbitem.Text = .Fields(0)
        frmpurchaseqty.cmbbrand.Text = .Fields(1)
        frmpurchaseqty.cmbpurchaseqty.Text = .Fields(2)
        frmpurchaseqty.purchasedt.Value = .Fields(3)
        frmpurchaseqty.cmbpurchaseqty.Text = .Fields(4)
        frmpurchaseqty.cmbsuppliername.Text = .Fields(5)
        frmpurchaseqty.cmbitemrefno.Text = .Fields(6)
        frmpurchaseqty.cmbsupplierrefno.Text = .Fields(7)
        'chkwarrenty.Value = .Fields(8)
        frmpurchaseqty.cmdwrrenty.Caption = .Fields(8)
        frmpurchaseqty.warrentyvoiddt.Value = .Fields(9)
    End With
    End If
    End Sub

    Reno



      Hopeful
    • Thanked: 32
      Re: Display all records one by one by using rst.movenext
      « Reply #1 on: May 23, 2009, 10:38:02 PM »
      assuming you have successfully create the connection and rst object.
      to iterate the recordset, pseudocode as below:

      Code: [Select]
      while not rst.eof
        msgbox rst.field(0)
        rst.movenext
      wend

      talorababu

        Topic Starter


        Rookie

        Re: Display all records one by one by using rst.movenext
        « Reply #2 on: May 23, 2009, 10:51:07 PM »
        Dear Sir

        Thanks for your prompt response.

        I have tried with your given code earlier but can't understand in which place I should place it.

        Would you please let me know?

        Regards
        Pervez

        talorababu

          Topic Starter


          Rookie

          Re: Display all records one by one by using rst.movenext
          « Reply #3 on: May 24, 2009, 06:50:22 AM »
          Dear Sir

          I have done it. Thanks for your nice co-operation.


          Regards
          talorababu