Another listbox question

dsmaj

Registered User.
Local time
Today, 14:19
Joined
Apr 28, 2004
Messages
96
Hey folks, here's my situation in a nutshell:
I've got a "Table/Query" type listbox that I am populating as follows:
-------------
SQLStatement = "SELECT * FROM tbl_StrategyDeliverables " & _
"WHERE StrategyID = " & ParentForm.txtID.Value
.
.
.
lstDeliverables.RowSourceType = "Table/Query"
lstDeliverables.RowSource = SQLStatement
lstDeliverables.Requery
-------------
This code and all the supporting code works fine...my question is this: I don't want to populate the listbox with all of the columns that my SELECT query has returned...I only need a few key columns. Is there a way (at runtime) to specify exactly which columns will be included in the listbox and in which order? Furthermore, is there a way for me to add custom column headers, rather than have just the field names from the database displayed?

Sorry if this is a rather elementary question...I'm somewhat new to access/VBA.

Thanks in advance,
Sam
 
Okay, I've figured out the custom headings thing (that was kind of a dumb question...sorry). How about the other part of my question though? How can I only import certain columns into the listbox?

Sam

Edit: While I'm rattling off questions...is it possible to get a horizontal scroll bar on my listbox?
 
Last edited:
New Day...any new ideas?

I should note as well that I realize I can return only the columns that I need from within my select statement...however, the application requires the other data, while the listbox does not. I'm looking to select only specific columns from my recordset to display in the list box....

Sam
 
Nobody has any ideas? Come on...I'm willing to try anything here!
 
Hiding Columns

Try this...

Right-click on the list box and go to Properties.

Under the Format Tab you will see column count and column width.

set the column count to the total number of columns.

Then, under column width, set any columns you don't want to 0";

Example.

if you have 3 fields in you SELECT Statement.


Name Number Date
x x x
x x x


SET:

column Count = 3
Then, if you only want Name and Date
Set Column Width = 1";0";1";

this will show

Name Date
x x
x x
 
Last edited:
Thanks!

In my case, I had 6 columns returned by my select statement, and I only wanted the third and the fourth columns to be displayed in the list box. Setting the Column Count to 2, and the column width's apropriately yielded an empty list box, however, setting the Column Count to 4 with the apropriate column widths worked perfectly! Thanks a lot for filling me in on column widths--I knew there had to be some kind of an easy solution to this...

Thanks again,
Sam
 

Users who are viewing this thread

Back
Top Bottom