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.
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.
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
Thanks for replying me i try to use the code but it's not working with me and need for multicolumn listBox.
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
Bookmarks