Results 1 to 2 of 2

Thread: My first database project

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2000
    Location
    Brooklyn Ohio
    Posts
    26
    This is my first database project in VB. I have a couple of questions that I would like to ask. I guess I'll use access for the database. Would the person I give the program to have to have Access. Also if I have 20 lines of numbers in a list box, how do I save it to 20 columns?
    And I would like to put it back in a list box later.

    Thank you for your help

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    You can use DAO to link to the Access Database from VB, and your client does not need to have Access installed on his machine.

    As for your second question, the nature of the question is strange, as usually each item in the listbox is updated in one row of the table, and not one column. However if the number of columns in the table are exactly the same as the number of items in the list, it is possible:

    Code:
    Dim I As Integer
    Dim rsTemp As RecordSet
    
    'Code to populate the listbox, and open the recordset
    
    rsTemp.AddNew
    For I = 0 To List1.ListCount - 1 Step 1
       rsTemp.Fields(I) = List1.List(I)
    Next
    rsTemp.Update
    The above code will insert a new blank row into the recordset and update each value in the listbox into each column of the new row. However, the number of columns in the recordset must match the number of items in the listbox. Now for retrieving values from the table into the list, just the reverse of the above:

    Code:
    Dim I As Integer
    Dim rsTemp As RecordSet
    
    'Code to open the recordset
    
    List1.Clear
    rsTemp.MoveFirst
    For I = 0 To rsTemp.Fields.Count - 1 Step 1
       List1.AddItem rsTemp.Fields(I)
    Next

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width