How can we add data from multiple columns of an access table in a list box.
Please explain with the help of a code.
Thanks in advance.

Recommended Answers

All 3 Replies

you need to open the recordset with multiple columns and then to add to the list box try this

list1.additem (rs(0)&"  " & rs(1) & "  " & rs(2))

ya thanks
I have got the result successfully!!
Thanks

Set rs = New ADODB.Recordset
strSQL = "select distinct windows from Master_final"
rs.Open strSQL, cn
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do While Not rs.EOF
windows = rs.Fields(0).Value
lstsoftware12.AddItem (windows)
rs.MoveNext
Loop
End If
rs.Close
strSQL = "select distinct office from Master_final"
rs.Open strSQL, cn
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do While Not rs.EOF
office = rs.Fields(0).Value
lstsoftware12.AddItem (office)
rs.MoveNext
Loop
End If
rs.Close
strSQL = "select distinct autocad from Master_final"
rs.Open strSQL, cn
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do While Not rs.EOF
autocad = rs.Fields(0).Value
lstsoftware12.AddItem (autocad)
rs.MoveNext
Loop
End If
rs.Close
strSQL = "select distinct PDF_Writer from Master_final"
rs.Open strSQL, cn
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do While Not rs.EOF
PDF_Writer = rs.Fields(0).Value
lstsoftware12.AddItem (PDF_Writer)
rs.MoveNext
Loop
End If
rs.Close
strSQL = "select distinct Primavera from Master_final"
rs.Open strSQL, cn
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do While Not rs.EOF
Primavera = rs.Fields(0).Value
lstsoftware12.AddItem (Primavera)
rs.MoveNext
Loop
End If
rs.Close
strSQL = "select distinct Etap from Master_final"
rs.Open strSQL, cn
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do While Not rs.EOF
Etap = rs.Fields(0).Value
lstsoftware12.AddItem (Etap)
rs.MoveNext
Loop
End If
rs.Close
strSQL = "select distinct Tally from Master_final"
rs.Open strSQL, cn
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do While Not rs.EOF
Tally = rs.Fields(0).Value
lstsoftware12.AddItem (Tally)
rs.MoveNext
Loop
End If
rs.Close
strSQL = "select distinct Caesar from Master_final"
rs.Open strSQL, cn
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do While Not rs.EOF
Caesar = rs.Fields(0).Value
lstsoftware12.AddItem (Caesar)
rs.MoveNext
Loop
End If
rs.Close
strSQL = "select distinct Staad from Master_final"
rs.Open strSQL, cn
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do While Not rs.EOF
Staad = rs.Fields(0).Value
lstsoftware12.AddItem (Staad)
rs.MoveNext
Loop
End If

here cn is the connection
this code has helped me succesfully complete what i wanted to achieve

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.