"Dynamic" listbox columns

  • Thread starter Thread starter Datawonk
  • Start date Start date
D

Datawonk

Hi All,

I have a form with a multi-column list box on it (unbound, loaded
through code). Based on values that the user selects (from a frame),
I would like to populate that single listbox with different columns and
data.

For Example, the Frame has two options: Applicant and Inquiry

If the user clicks on applicant, I want to load the listbox with a
subset of data from the applicant table. If the user clicks on
Inquiry, I want to load the same listbox with data from the inquiry
table (with a different number of columns).

I have no problem getting the data into the listbox, but I cannot
remember for the life of me how to set the number of columns and column
widths in the code. I know you can do this, but I can't find an
example anywhere.

To paraphrase what I want the code to do:

If FrameSearch = 1 then

build my query (I know how to do this)
set number of columns in listbox
set widths of columns in listbox
execute query and bind to listbox (I know how to do this)

End if

Thank you for any help you can provide.

Birgit
 
The properties Me.MyList.ColumnCount and Me.MyList.ColumnWidths are probably
those that you are looking for.

If you are using a function as the row source type of your listbox, then the
required constants are acLBGetColumnCount and acLBGetColumnWidth.

Others possibilities for you would be to use two list boxes and hide/unhide
them as necessary or to use a continuous subform.
 
Back
Top