Load partial rs into listbox

G

Guest

OK - This one has me stumped.
I need a way to filter out some of the columns from a recordset and load
them into a listbox. The reason why I don’t SELECT exactly what I need is
that I still need to use data from other columns, its this information that I
dont want to load into the listbox. In other words I'm trying not to
cluttering the listbox with bazillion columns, but I still need all the
information to work with in the background.

Any ideas? This is what I'm working from.

With rs
.ActiveConnection = conn
.LockType = adLockBatchOptimistic
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.Open "select * from getcustomer"
.ActiveConnection = Nothing
End With

'Add recordset to Listbox
With List0
.RowSourceType = "Table/Query"
.ColumnCount = rs.Fields.Count
.ColumnHeads = True
End With
Set List0.Recordset = rs ' Presently this loads everything and I need to
restrict
 
S

Stefan Hoffmann

hi,
I need a way to filter out some of the columns from a recordset and load
them into a listbox.
With rs
.Open "select * from getcustomer"
If you really mean filtering columns, then you have to specify the
desired columns instead of using * for all fields.
'Add recordset to Listbox
With List0
.RowSourceType = "Table/Query"
.ColumnCount = rs.Fields.Count
.ColumnHeads = True
Use .ColumnWidths = "0;0;1;2"
to control wether the columns will be displayed or not.
Set List0.Recordset = rs ' Presently this loads everything and I need to
restrict


mfG
--> stefan <--
 
G

Guest

Hi,

This is a simpler way to explain. Say my first record has this return below
and the arrows below it is what I want to populate a listbox with.
RS Values = ABC1234, Bill, Gates, 212-222-2222, Talks like Kermit Da Frog
^ ^
^
Listbox Entry = Bill, Gates, Kermit Da Frog

So for another use when I select this rs in the listbox I can see where it's
position is and referance back to the rs and get the value from the first
column, example ABC1234. FYI - I store the recordset in a global variable.
 
J

John Spencer

Load the listbox with all the fields you want to use.
Use the column width properties to hide the display of colums you don't want the
user to see.

You hide a column by setting its width to zero. You can have columns
automatically size by leaving the value blank

1;0;;1.5;0;0

First column one inch, next column hidden, next column at least one inch based
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top