Record Count

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pa2ratczi
    New Member
    • Mar 2007
    • 19

    Record Count

    Hi i need help guys, can some body tell how to count records and display it in a label,,, i have a program that has a database in access, a simple databse program, i use adodc,,, the program stores name, address, phone number, and student number, its already running, but the thing is i wanted to be able to display how many records do i have in my program,

    hope there's someone who can help or give an idea on how to solve my problem. thank you in advance.
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Hi. Can you post the code you have already at the point you want to count the records please?

    Comment

    • pa2ratczi
      New Member
      • Mar 2007
      • 19

      #3
      Code:
      Private Sub Command2_Click()
      
      
      If Adodc1.Recordset.EOF = True Then
          MsgBox ("No more Records")
      Text1.Locked = True
      Text2.Locked = True
      Text3.Locked = True
      Text4.Locked = True
      
      End If
      End Sub
      
      Private Sub Command3_Click()
      Adodc1.Recordset.MovePrevious
      
      If Adodc1.Recordset.BOF = True Then
          MsgBox ("No more Previous Records")
      End If
      
      End Sub

      So far that the code am still workin for ADDING & DELETING records, for the mean time am adding records through access but not in the program it self, thats one thing i need to know on how i can add & delete records without going to microsoft access...
      Last edited by willakawill; Mar 9 '07, 04:13 PM. Reason: please use [code]...[/code] tags when posting code

      Comment

      • willakawill
        Top Contributor
        • Oct 2006
        • 1646

        #4
        This should get you the number of records:
        Code:
        Adodc1.Recordset.MoveLast
        txtRecordCount.Text = Adodc1.Recordset.RecordCount
        Adding and Deleting will be in your help for adodc
        You should give your command buttons useful names so that you can distinguish between them in code e.g.
        cmdAddNew
        or
        cmdMoveNext

        Comment

        • vijaydiwakar
          Contributor
          • Feb 2007
          • 579

          #5
          Originally posted by pa2ratczi
          Hi i need help guys, can some body tell how to count records and display it in a label,,, i have a program that has a database in access, a simple databse program, i use adodc,,, the program stores name, address, phone number, and student number, its already running, but the thing is i wanted to be able to display how many records do i have in my program,

          hope there's someone who can help or give an idea on how to solve my problem. thank you in advance.
          see this can be done in 2 ways use qry like select count(1) from tblname
          count(1) is available in ora
          and other way is to use recordcount as willakawill sugets

          Comment

          • pa2ratczi
            New Member
            • Mar 2007
            • 19

            #6
            hello ive just figured out how to make my program work as i want too.
            for contributions here my code::

            Private Sub Command1_Click( )

            adoConnect.Reco rdset.AddNew
            Text1.SetFocus


            End Sub

            Private Sub Command2_Click( )
            If Text1.Text = "" And Text2.Text = "" Then
            MsgBox ("No record/s deleted"), vbCritical
            Text1.Text = "<Blank>"
            Text2.Text = "<Blank>"

            Else
            adoConnect.Reco rdset.Delete
            adoConnect.Refr esh
            adoConnect.Reco rdset.MoveNext
            adoConnect.Refr esh
            MsgBox ("Record Deleted!")
            End If

            End Sub

            Private Sub Command3_Click( )
            Dim ans As String


            If Text1.Text = "" And Text2.Text = "" Then
            ans = MsgBox("No more previous records!!! " & _
            "Do you want to procedd?", vbYesNo)
            adoConnect.Reco rdset.MoveFirst

            Else
            adoConnect.Reco rdset.MovePrevi ous
            End If


            End Sub

            Private Sub Command4_Click( )
            Dim ans As String


            adoConnect.Reco rdset.MoveNext

            If adoConnect.Reco rdset.EOF = True Then
            ans = MsgBox("No more Records!!! " & _
            "Do you want to procedd?", vbYesNo)

            If ans = vbNo Then
            End
            Else

            adoConnect.Reco rdset.MoveFirst


            End If
            End If






            End Sub

            Private Sub Command5_Click( )

            Label1.Caption = adoConnect.Reco rdset.RecordCou nt & " " & "Record/s"


            End Sub

            Private Sub Command6_Click( )
            If Text1.Text = "" And Text2.Text = "" Then
            MsgBox ("Cannot save blank entries!"), vbCritical
            Else
            MsgBox ("Record was save")
            adoConnect.Reco rdset.Update

            End If

            If Text1.Text = "<Blank>" And Text2.Text = "<Blank>" Then
            MsgBox ("Record was save!"), vbCritical
            adoConnect.Reco rdset.Update
            End If

            End Sub



            thanks for all the help!!!! i really appreciate it... Thank you VB Masters.

            Comment

            Working...