Community discussion forum

how to know the number of record in vb

  • 8 months ago

    Hi, how can i display the number of same record. For example i have record with customer no. 2444 and there's a lot of record for this customer. how can i show that the customer have a lot of records. for example "There is 24 record for customer 2444 ". Thanks

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 8 months ago

    You can do a count of the records in the database

    Execute the following SQL and it will return the count.

    SELECT count(*) FROM Your_TABLE WHERE customerNumber='2444'

     

  • 8 months ago

    well im using Access database in vb and im hoping that u can teach me how to do so in vb 6, where if i put 2444 in text box for searching that customer and i want it to display the number of records in label...

  • 8 months ago

     well im using Access database in vb and im hoping that u can teach me how to do so in vb 6, where if i put 2444 in text box for searching that customer and i want it to display the number of records in label...

  • 8 months ago

    Using DAO ( add a reference to Microsoft DAO...) 

         Dim db As Database
        Dim rs As DAO.Recordset
        Set db = OpenDatabase("c:\mydatabase.mdb")
        Set rs = db.OpenRecordset("SELECT count(*) FROM Your_TABLE WHERE customerNumber=" & Text1.Text)
        rs.MoveFirst
        Label1.Caption = rs.Fields(0) & " records for customerNumber : " & Text1.Text
        Set rs = Nothing
        Set db = Nothing

     

  • 8 months ago

    is there any other way to do it without using sql..i don't really know sql and i use data control to connect access to vb.. 

  • 8 months ago

    There are many ways to do something like this, you never specified how you were connecting to the database.

    Try 

     Data1.RecordSource = "SELECT *  FROM Your_TABLE WHERE Your_TABLE.customerNumber = " & Text1.Text
     Data1.Refresh
     Data1.Recordset.MoveLast
     Label1.Caption = Data1.Recordset.RecordCount

     ** Change the Your_TABLE to the name of your table & customerNumber to the name of the field

  • 8 months ago

    oh..sorry about that..i'm using usejet to connect to the database..so is there anyway

Post a reply

Enter your message below

Sign in or Join us (it's free).