Results 1 to 8 of 8

Thread: Access Table and Listbox Please Help!

  1. #1

    Thread Starter
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    Angry

    How would I get all the information from 1 column in my access database, to show up in a listbox? I was playing around with the "design view" and i saw under the "lookup" tab, that you can use it in a listbox, will someone please inform me here, great thanks!

  2. #2
    Guest

    Thumbs up Don' use databinding...and use a combo box

    Dim db as database
    Dim rs as recordset
    '
    ' Set to whatever
    '
    If not rs.EOF and not rs.BOF Then
    rs.MoveFirst
    cboText.Clear
    Do
    cboText.AddItem rs!Whateverfield
    rs.Movenext
    if rs.EOF Then Exit Do
    Loop
    cboText.ListIndex = 0
    Else
    ' Whatever error or Message
    End If

    Hope it helps...am using vb5 sp 3

  3. #3

    Thread Starter
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    sorry

    sorry, im not familiar with what you were trying to tell me there, im just beginning. All I want to do is transfer all data from a column to a listbox as easly and painlessly as possible, thanks again

  4. #4

  5. #5
    Guest

    Hmmmm..........

    Ok in my version of vb there is no quick and dirty way of transferring an entire column of data from an access db to a listbox or combobox.

    What the code does is

    1. Sets the db and rs to the required database and recordset

    2. Tests if the recordset has any data in it.

    3. Loops through the recordset and adds the individual column items to a combobox.

    Not all that difficult.....if you need any help ask specific questions about the code...maybe someone will post a better solution for you:0

  6. #6

    Thread Starter
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249
    what do i do, i have multiple databases on the form

  7. #7
    Guest

    Smile Ok shouldn't matter

    No problems. Each database is going to be uniquely identified and each recordset is opened against a particular database right....

    Therefore if you have three database db1 db2 db3

    the setting for a recordset is gotta be something like

    Set rs to db1.openrecordset(whatever)

    Therefore the fact that db2 & db3 are on the same form doesn't affect processing of the recordset in db1.

    The same logic no doubt applies to databinding...but it's the first rule in our company's programming guide lines "No use of data binding"...therefore caren't help you with code for that situation.

    Hope this helps

  8. #8
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Smie!

    In Design view of the from, drop a listbox on your form and type in a select statement similar to the one below into the "Rowsource" Property!

    "SELECT DISTINCTROW [ProductID],[ProductName] FROM [Products Table];"

    Make sure the "RowSource Type = Table/Query"


    If you have trouble typing the select statement, put your cursor on the "RowSource" property and click on the elipsee. Make sure your select statement includes the primary key too.

    Or another alternative is just selecting the table from "Rowsource" Property and the column you want to "BOUND" property.
    Chemically Formulated As:
    Dr. Nitro

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