Doubt in vb application

Posted on 2004-11-04
Last Modified: 2012-05-05
hello sir,
       I have data records as "staff code"& "test" in MS access
In vb List box I have to dispaly the tests that are passed by there staff code.even same staff code may passed different
tests,that should be displayed in the list box..

          thank you
Question by:sivara
    1 Comment

    Accepted Solution

    Although, you question seems hazy, you'd had better tried ADO's Command object & Recordset object to parse the SQL queries in response to your needs, and build up the listbox by using the recordset. A simple example may be like :

    Private Function PopulateStaffCode() as Boolean
    On Error goto ErrorHandler
    Dim xConn as new ADODB.Connection
    Dim xRs as new ADODB.Recordset

    xConn.Open "<Connection String>"
    xRs.Open "Select staffcode from <table name>",xConn, & _

    while not xRs.EOF=TRUE
       lstStfCode.AddItem xrs.Fields(0).value
    Exit Function
    End Function

    Private Function PopulateTestRecord() as Boolean
    Dim xConn as New ADODB.Connection
    Dim xRs as New ADODB.Recordset

    xConn.Open "<Connection String>" "select test from <table name> where staffcode=" & trim(lstStfCOde.item(lstStfCode.ListIndex)),xConn,adOpenForwardOnly, & _
    adLockOptimistic, adCMDTable

    While Not xRs.EOF=TRUE
       lstTestRec.AddItem xRs.Fields(0).Value
    Exit Function
    End Function

    The first function will populate a listbox named lstStfCode by code of all the staff. The next function will populate the next listbox named lstTestRec by details of all the test performed by the staff selected in the first listbox.

    May be it will help. For more details you may contact me at

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Suggested Solutions

    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now