Lists Loading

Posted on 2005-04-13
Last Modified: 2011-09-20

i have two lists the first inclueds six cars and the second list will display the parts for that car . so each time choose can only
view a list for one car only. then click a button to go to next screen after choosing a part from list.

Then read in from a sequential text file info on that part and print info of list items chosen and part info in a picture box on the screen .  

a idea of how text file looks : "ford","2254",Flywheel","330000"(car name, price, part , total value) i only want to display info on selected items from list not whole file .

i dont know how to do this and make it work.  
Question by:AlanPockley
    LVL 5

    Expert Comment

    There are many ways to do this, but two ways I can think of are firstly that you create a data structure e.g.

    Private Type CarPartRecord

       Brand as string
       PartNo as long
       PartDesc as string

    End Type

    Then you would need to create an array to read this information from the file into it.

    Now if you take a more structured approach and use ADO disconnected recordsets you can save on grief and extra coding.
    You could simply create a drs to hold your car parts and then save it as an ADO ADTG to hard disk (similar to file, but saving and reading it back are less grief than creating arrays and messing with UDTs). e.g.

    Dim adoRs As ADODB.Recordset
        ' Build ADO Rs Error Structure
        Set adoRs = New ADODB.Recordset
        With adoRs

            .CursorLocation = adUseClient
            .LockType = adLockBatchOptimistic
            .Fields.Append "BrandName", adVarChar, 255, adFldMayBeNull
            .Fields.Append "PartDesc", adVarChar, 255, adFldMayBeNull
            .Fields.Append "PartNo", adLongVarWChar, 250000, adFldMayBeNull

       End With

    Now you would use ADO's .AddNew and .Update to add or amend records.

    To save it to HardDisk simply use .Save strFilePathName, adPersistADTG

    Then when you want to open it from Hard Disk simply use

            Set adoRs = New ADODB.Recordset
            adoRs.CursorLocation = adUseClient
            adoRs.Open strFilePathName

    To search the part number or name use the .Filter or .Find method.
    LVL 85

    Accepted Solution

    How big is the text file?  If it isn't too big then we can walk the file and build a set of collections that correspond to the parts belonging to each car, populating the car list as we go.  Then when a car is selected, we repopulate the parts list from the corresponding collection in memory.

    If you post some more entries from the text file, perhaps at least 3 parts from each car, then I can give you an example.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Introduction This article makes the case for using two modules in your VBA/VB6 applications to provide both case-sensitive and case-insensitive text comparison operations.  Recently, I solved an EE question using the LIKE function.  In order for th…
    When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    779 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

    12 Experts available now in Live!

    Get 1:1 Help Now