Results 1 to 3 of 3

Thread: [RESOLVED] How do I populate a DataListBox during runtime?

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2015
    Posts
    46

    Resolved [RESOLVED] How do I populate a DataListBox during runtime?

    Hi all,
    I have a DataGrid on my form which is ok and works.. I want to get rid of the DataGrid and use a DataList, How do I do it. The code that I am using to fill my DataGrid is below:

    Code:
    Private Sub Form_Load()
    cn.CursorLocation = adUseClient
    cn.Open "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=testitem;User=root;Password=mysql;Option=3;
    End Sub"
    
    Private Sub Command1_Click()
    rs.Open "select * from item where itemname = '" & Text9.Text & "'", cn, adOpenDynamic, adLockOptimistic
    Set DataList1.RowSource = rs
    DataList1.DataField = itemno
    Set DataGrid3.DataSource = rs
    End Sub
    The datagrid gets populated just fine but the datalist is always empty

    What am I missing here?
    Please help.

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: How do I populate a DataListBox during runtime?

    DataList1.ListField = itemno instead of DataList1.DataField = itemno

    Never used one, but Google suggests this

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2015
    Posts
    46

    Re: How do I populate a DataListBox during runtime?

    mybad.....
    Thanks a bunch

    working code:
    Code:
    DataList1.ListField = "itemno"

Tags for this Thread

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