Results 1 to 4 of 4

Thread: Populating an Access 2003 list box with vb6

  1. #1
    Join Date
    Jan 2009
    Posts
    91

    Populating an Access 2003 list box with vb6

    Hello friends,

    I have a vb6 form and a ms access file that has stored in it a table.That table contains 3 columns(ID,Username, Password).
    All i wanted was when the form loads i want that the access list should get populated.

  2. #2
    Join Date
    Dec 2008
    Posts
    101

    Re: Populating an Access 2003 list box with vb6

    Sure i will help you out with this try to use the following code hope it will work for you.

    HTML Code:
    Private Sub Form_Load()
    Dim rs As New ADODB.Recordset
    Dim strConnectionString As String
    Dim strSQL As String
    
    
    On Error GoTo Handler:
    strConnectionString = ""
    strSQL = "select * from tblUsers"
        
    rs.Open strSQL, strConnectionString
    If Not (rs.EOF And rs.BOF) Then
        rs.MoveFirst
        Do While Not rs.EOF
            strID = rs.Fields(0).Value
            strName = rs.Fields(1).Value
            strPassword = rs.Fields(2).Value
            Call AddToListBox(strID, strName, strPassword)
            rs.MoveNext
        Loop
    Else
        MsgBox "No records found."
    End If
    
    My_Exit_Sub:
    On Error Resume Next
    rs.Close
    Set rs = Nothing
    Exit Sub
    Handler:
    MsgBox "Error " & Err.Number & ": " & Err.Description
    Resume My_Exit_Sub
    End Sub
    
    Private Sub AddToListBox(ByVal strID As String, ByVal strName As String, _
        ByVal strPassword As String)
    
        MsgBox "Code to add to list box executes now."
    
    End Sub

  3. #3
    Join Date
    Jan 2009
    Posts
    91

    Re: Populating an Access 2003 list box with vb6

    Thanks for replying me i try to use the code but it's not working with me and need for multicolumn listBox.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Populating an Access 2003 list box with vb6

    Try to use this code i am sure it will work for you.


    HTML Code:
    Private Sub Command1_Click()
    
     List1.RowSource = ""
    
     List1.RowSourceType = "Value List"
    
     List1.ColumnCount = 3
    
     List1.ColumnWidths = "500;500;500"
    
     List1.AddItem "111;222;333"
     List1.AddItem "444;555;666"
    End Sub

    Intel Core 2 Duo 2.8 Ghz
    G31 Asrock Motherboard with Intel chipset
    1gb RAM
    120gb HDD

Similar Threads

  1. How can I make Calendar Auto-Populating in MS Excel
    By Fitroy in forum Windows Software
    Replies: 6
    Last Post: 10-07-2011, 11:13 AM
  2. Read Access 2003 files with Access 2007
    By Kendal-J in forum Windows Software
    Replies: 2
    Last Post: 26-05-2010, 05:57 PM
  3. Populating sqlite database on iphone
    By tecHAMMER in forum Software Development
    Replies: 3
    Last Post: 01-10-2009, 10:48 AM
  4. Replies: 1
    Last Post: 21-09-2008, 09:05 AM
  5. Remote Access and Outlook Web Access on SBS 2003
    By mannuraama in forum Small Business Server
    Replies: 4
    Last Post: 04-06-2008, 04:22 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,983,849.49118 seconds with 16 queries