Multiselect Listbox

G

gatarossi

Dear all,
I'm trying to build a form for expenses forecast. Then I have a form
and a subform coupled. It is like that:
Form
profit_center: (combobox with all profits center)
date: (listbox with all dates)
Subform
textbox textbox1 textobox2 textbox3
textbox4 textbox5 ...
expenses_code date1 date2
date3 date4 date5 ...
In my form there is a multiselect listbox. Inside this listbox there
are some dates, for example: 01/01/07, 01/02/07, 01/03/07,
01/04/07...
I made a code that consist: each time that I select one date in my
multiselect listbox, in my subform appear one textbox. The problem
is:
In my subform there are only 12 textbox and in the multiselect
listbox
can exist more than 12 dates, and the code below in not flexible,
because I only can use the first twelve dates from the sequence of
dates in the multiselect listbox; and I would like that it pick the
first 12 dates that the user selected.
When the user opens de form all columns in my subform related with
the
listbox date will be occult. Then when the user select one date, one
column will appear (these columns can't be related with the date,
like
I show in my code - it's the problem!).
For example:
In the code below, if I click in 01/01/07 it will appear the
textbox1,
if I click in 01/02/07 it will appear the textbox2.
But If I only click in 01/02/07, I would like that appear the
textbox1, not the textbox2.
This is the code:
Private Sub lstdata_Click()
If lstdata.Selected(0) = True Then
Me!despesas_subform!txtp1.ColumnHidden = False
Else
Me!despesas_subform!txtp1.ColumnHidden = True
End If
If lstdata.Selected(1) = True Then
Me!despesas_subform!txtp2.ColumnHidden = False
Else
Me!despesas_subform!txtp2.ColumnHidden = True
End If
If lstdata.Selected(2) = True Then
Me!despesas_subform!txtp3.ColumnHidden = False
Else
Me!despesas_subform!txtp3.ColumnHidden = True
End If
..
..
..
End Sub
Thanks!
André.
 
P

Paterson

I'm not exactly sure what the outcome is supposed to be once you get all the
txt boxes, but you might be able to do something like this:

Create a table with two fields (date and text) to hold the information and
create tabular form as your subform to display them. You could have a
separate record on your table corresponding to all of your dates. if there
are an unkown amount of dates you could use the multiselect listbox to create
the record if it hasn't yet, or simply show it if italready exists. You
could hide the ones created, but not currently selected in the listbox, by
filtering.

I'm really not sure how to implement this, but it's an idea.
 

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