Default value for multi-select list box

  • Thread starter MOGSY via AccessMonster.com
  • Start date
M

MOGSY via AccessMonster.com

Hi. I have a unbound, simple multi-select list box (of employees), that's
using a table for it's row source type. I currently have it set so that when
a user selects an employee from the list, a text box is populated with that
employee. I would like to have a default value of "Choose employee(s)" in the
list box so that when the user opens the form it is there AND after each
selection of employee. How can I do this with a multi-select?

Thanks!
 
D

Damon Heron

That doesn't sound very efficient. Why not just have a label that says
"Choose Employee(s)"??
Adding it to a listbox doesn't improve the listbox....

Damon
 
M

MOGSY via AccessMonster.com

I need to do it this way for clarity and space. The list box contains many
employee names so that in order for the form to display the choosen ones I
have them appearing in a text box after the user has selected them. The list
box itself is sized to display only one name at a time. I suppose I can leave
it as is... I would prefer to have a default value though...

Damon said:
That doesn't sound very efficient. Why not just have a label that says
"Choose Employee(s)"??
Adding it to a listbox doesn't improve the listbox....

Damon
Hi. I have a unbound, simple multi-select list box (of employees), that's
using a table for it's row source type. I currently have it set so that
[quoted text clipped - 7 lines]
 
D

Damon Heron

And what happens if they choose the default value (Choose Employees)?
Also, if you are using a multiselect listbox, and displaying only one row,
why not just use a combobox?
That way, the combobox can dropdown when entered and show a quantity of
names - the listbox with only one row requires scroll buttons from the first
to the last. You could put your code in the afterupdate event of the
combobox to add to the textbox list.

Damon

MOGSY via AccessMonster.com said:
I need to do it this way for clarity and space. The list box contains many
employee names so that in order for the form to display the choosen ones I
have them appearing in a text box after the user has selected them. The
list
box itself is sized to display only one name at a time. I suppose I can
leave
it as is... I would prefer to have a default value though...

Damon said:
That doesn't sound very efficient. Why not just have a label that says
"Choose Employee(s)"??
Adding it to a listbox doesn't improve the listbox....

Damon
Hi. I have a unbound, simple multi-select list box (of employees),
that's
using a table for it's row source type. I currently have it set so that
[quoted text clipped - 7 lines]
 
M

MOGSY via AccessMonster.com

I thought you couldn't have a multi-select ComboBox? (Because, yes, a combo
box would definitely make it easier for choosing).

I would like "Choose Employee" to be displayed each time they select one and
their selection is populated into the text box (for display purposes only).

Thanks.

Damon said:
And what happens if they choose the default value (Choose Employees)?
Also, if you are using a multiselect listbox, and displaying only one row,
why not just use a combobox?
That way, the combobox can dropdown when entered and show a quantity of
names - the listbox with only one row requires scroll buttons from the first
to the last. You could put your code in the afterupdate event of the
combobox to add to the textbox list.

Damon
I need to do it this way for clarity and space. The list box contains many
employee names so that in order for the form to display the choosen ones I
[quoted text clipped - 16 lines]
 
L

Linq Adams via AccessMonster.com

Replace your combobox/listbox RowSource with this

SELECT YourField FROM YourTable
UNION SELECT "<Choose Employees>" FROM YourTable;

filling in your actual field and table names.

Comboboxes only gained 'multi-select' capability with version 2007. On
earlier versions you can 'spoof' this behavior with something linke this:

Private Sub YourComboBox_AfterUpdate()
If IsNull(Me.HoldingBox) Then
Me.HoldingBox = Me.YourComboBox
Me.YourComboBox = "<Choose Employees>"

Else
Me.HoldingBox = Me.HoldingBox & ", " & Me.YourComboBox
Me.YourComboBox = "<Choose Employees>"
End If
End Sub

where HoldingBox is the name of the textbox that holds the names after
selection. It should be noted, however, that storing multiple pieces of data
(employee names, in this case) in a single field is frowned upon.
 
M

MOGSY via AccessMonster.com

Thank you very much! It works beautifully! One more small thing... How can I
get the selected items which are being displayed in the textbox to be
displayed as a list (one name per line), instead of using commas?

Thanks again!
 
P

PieterLinden via AccessMonster.com

MOGSY said:
Thank you very much! It works beautifully! One more small thing... How can I
get the selected items which are being displayed in the textbox to be
displayed as a list (one name per line), instead of using commas?

Thanks again!
Replace your combobox/listbox RowSource with this
[quoted text clipped - 20 lines]
selection. It should be noted, however, that storing multiple pieces of data
(employee names, in this case) in a single field is frowned upon.


instead of & ", " &
use & vbCrLf &
 
M

MOGSY via AccessMonster.com

Thank you!
Thank you very much! It works beautifully! One more small thing... How can I
get the selected items which are being displayed in the textbox to be
[quoted text clipped - 7 lines]
instead of & ", " &
use & vbCrLf &
 

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