PC Review


Reply
Thread Tools Rate Thread

Help with Multiselect List Box

 
 
=?Utf-8?B?TWljaGVsbGU=?=
Guest
Posts: n/a
 
      31st Jul 2007
I have the following code that allows the user to select items in a list box
and show them in a text box. However, if the user comes back to a record and
wants to add additional names to the text box, it clears out the previous
selection.

Here is my code:

Dim varItem As Variant
Dim strList As String

With Me.Employee
If .MultiSelect = 0 Then
Me.Employee = .Value
Else

For Each varItem In .ItemsSelected
strList = strList & .Column(0, varItem) & vbCrLf
.Selected(varItem) = False 'unselect listbox

Next varItem
If strList <> "" Then
strList = Left$(strList, Len(strList) - 1)
End If
Me.Employee = strList
End If

End With

Can anyone help with the code of adding additional employees to the text box
while keeping any original employees previously selected. Thanks.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      31st Jul 2007
I assume Me.Employee is the text box, but assuming it is:
Me.Employee = Me.Employee & ", " & strList

Not sure why you need to put multiple names in one text box, but this will
do it.
--
Dave Hargis, Microsoft Access MVP


"Michelle" wrote:

> I have the following code that allows the user to select items in a list box
> and show them in a text box. However, if the user comes back to a record and
> wants to add additional names to the text box, it clears out the previous
> selection.
>
> Here is my code:
>
> Dim varItem As Variant
> Dim strList As String
>
> With Me.Employee
> If .MultiSelect = 0 Then
> Me.Employee = .Value
> Else
>
> For Each varItem In .ItemsSelected
> strList = strList & .Column(0, varItem) & vbCrLf
> .Selected(varItem) = False 'unselect listbox
>
> Next varItem
> If strList <> "" Then
> strList = Left$(strList, Len(strList) - 1)
> End If
> Me.Employee = strList
> End If
>
> End With
>
> Can anyone help with the code of adding additional employees to the text box
> while keeping any original employees previously selected. Thanks.

 
Reply With Quote
 
=?Utf-8?B?TWljaGVsbGU=?=
Guest
Posts: n/a
 
      1st Aug 2007
Dave, I put your code in but it still cleared the previous names out of the
text box. I am curious about your comment "not sure why you need to put
multiple names in one text box" and was wondering if maybe there was a better
way to do what I want?

I have a list of employees in a table and the user needs to be able to
choose anywhere from 1 to 100 employees that could be associated with a
particular record in my database. It's a training database and we need to
see who is trained in that particular area. The user would like the list of
employees to choose from and would like to highlight each employee and show
what employees were highlighted. They would also like to be able to come
back and add additional employees to the text box. If there is a better way
to do this, I'm open to suggestions. (I didn't explain it clearly, please
let me know). Thanks again for your help.

"Klatuu" wrote:

> I assume Me.Employee is the text box, but assuming it is:
> Me.Employee = Me.Employee & ", " & strList
>
> Not sure why you need to put multiple names in one text box, but this will
> do it.
> --
> Dave Hargis, Microsoft Access MVP
>
>
> "Michelle" wrote:
>
> > I have the following code that allows the user to select items in a list box
> > and show them in a text box. However, if the user comes back to a record and
> > wants to add additional names to the text box, it clears out the previous
> > selection.
> >
> > Here is my code:
> >
> > Dim varItem As Variant
> > Dim strList As String
> >
> > With Me.Employee
> > If .MultiSelect = 0 Then
> > Me.Employee = .Value
> > Else
> >
> > For Each varItem In .ItemsSelected
> > strList = strList & .Column(0, varItem) & vbCrLf
> > .Selected(varItem) = False 'unselect listbox
> >
> > Next varItem
> > If strList <> "" Then
> > strList = Left$(strList, Len(strList) - 1)
> > End If
> > Me.Employee = strList
> > End If
> >
> > End With
> >
> > Can anyone help with the code of adding additional employees to the text box
> > while keeping any original employees previously selected. Thanks.

 
Reply With Quote
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      1st Aug 2007
Sorry, Michelle, I misread your post earlier. That was not actually the
problem. Now that I examine it a bit closer, I don't see the problem. I am
wondering if this
line:
.Selected(varItem) = False 'unselect listbox
Could be the problem. This is not an answer but a suggestion on where to
look. In some looping circumstances, when you modify the number of items in
the list, it can cause the loop control logic to become confused. In any
case, here is a trick for unselecting everything in a list box:

Me.MyListBox.ListIndex = -1

--
Dave Hargis, Microsoft Access MVP


"Michelle" wrote:

> Dave, I put your code in but it still cleared the previous names out of the
> text box. I am curious about your comment "not sure why you need to put
> multiple names in one text box" and was wondering if maybe there was a better
> way to do what I want?
>
> I have a list of employees in a table and the user needs to be able to
> choose anywhere from 1 to 100 employees that could be associated with a
> particular record in my database. It's a training database and we need to
> see who is trained in that particular area. The user would like the list of
> employees to choose from and would like to highlight each employee and show
> what employees were highlighted. They would also like to be able to come
> back and add additional employees to the text box. If there is a better way
> to do this, I'm open to suggestions. (I didn't explain it clearly, please
> let me know). Thanks again for your help.
>
> "Klatuu" wrote:
>
> > I assume Me.Employee is the text box, but assuming it is:
> > Me.Employee = Me.Employee & ", " & strList
> >
> > Not sure why you need to put multiple names in one text box, but this will
> > do it.
> > --
> > Dave Hargis, Microsoft Access MVP
> >
> >
> > "Michelle" wrote:
> >
> > > I have the following code that allows the user to select items in a list box
> > > and show them in a text box. However, if the user comes back to a record and
> > > wants to add additional names to the text box, it clears out the previous
> > > selection.
> > >
> > > Here is my code:
> > >
> > > Dim varItem As Variant
> > > Dim strList As String
> > >
> > > With Me.Employee
> > > If .MultiSelect = 0 Then
> > > Me.Employee = .Value
> > > Else
> > >
> > > For Each varItem In .ItemsSelected
> > > strList = strList & .Column(0, varItem) & vbCrLf
> > > .Selected(varItem) = False 'unselect listbox
> > >
> > > Next varItem
> > > If strList <> "" Then
> > > strList = Left$(strList, Len(strList) - 1)
> > > End If
> > > Me.Employee = strList
> > > End If
> > >
> > > End With
> > >
> > > Can anyone help with the code of adding additional employees to the text box
> > > while keeping any original employees previously selected. Thanks.

 
Reply With Quote
 
=?Utf-8?B?TWljaGVsbGU=?=
Guest
Posts: n/a
 
      1st Aug 2007
Dave, when I put in the line

Me.MyListBox.ListIndex = -1

I get a runtime error "7777" and the message "you've listed the ListIndex
property incorrectly". I substituted "Employee" for "MyListBox"??

Anyway, I'm so confused on this multi selection list box. I also found that
if I select a lot of names, it says my field is too small. I have the field
set as memo and the field size as 255. Is there a better way to do what I
want? I've been reading about using a subform but I must be extra blonde
today because it's just not clicking with me!

My main objective is to select names from "Employees" list box (it's
actually a table called Hourly Employee Table for Quality Alert) and there
are 863 names in this table and I would like to be able to highlight from
1-863 names if needed. I want to show the selection in another text box,
combo box, form, or whatever I can, just to show who was selected for each
record. Any suggestions are appeciated. Thanks.



"Klatuu" wrote:

> Sorry, Michelle, I misread your post earlier. That was not actually the
> problem. Now that I examine it a bit closer, I don't see the problem. I am
> wondering if this
> line:
> .Selected(varItem) = False 'unselect listbox
> Could be the problem. This is not an answer but a suggestion on where to
> look. In some looping circumstances, when you modify the number of items in
> the list, it can cause the loop control logic to become confused. In any
> case, here is a trick for unselecting everything in a list box:
>
> Me.MyListBox.ListIndex = -1
>
> --
> Dave Hargis, Microsoft Access MVP
>
>
> "Michelle" wrote:
>
> > Dave, I put your code in but it still cleared the previous names out of the
> > text box. I am curious about your comment "not sure why you need to put
> > multiple names in one text box" and was wondering if maybe there was a better
> > way to do what I want?
> >
> > I have a list of employees in a table and the user needs to be able to
> > choose anywhere from 1 to 100 employees that could be associated with a
> > particular record in my database. It's a training database and we need to
> > see who is trained in that particular area. The user would like the list of
> > employees to choose from and would like to highlight each employee and show
> > what employees were highlighted. They would also like to be able to come
> > back and add additional employees to the text box. If there is a better way
> > to do this, I'm open to suggestions. (I didn't explain it clearly, please
> > let me know). Thanks again for your help.
> >
> > "Klatuu" wrote:
> >
> > > I assume Me.Employee is the text box, but assuming it is:
> > > Me.Employee = Me.Employee & ", " & strList
> > >
> > > Not sure why you need to put multiple names in one text box, but this will
> > > do it.
> > > --
> > > Dave Hargis, Microsoft Access MVP
> > >
> > >
> > > "Michelle" wrote:
> > >
> > > > I have the following code that allows the user to select items in a list box
> > > > and show them in a text box. However, if the user comes back to a record and
> > > > wants to add additional names to the text box, it clears out the previous
> > > > selection.
> > > >
> > > > Here is my code:
> > > >
> > > > Dim varItem As Variant
> > > > Dim strList As String
> > > >
> > > > With Me.Employee
> > > > If .MultiSelect = 0 Then
> > > > Me.Employee = .Value
> > > > Else
> > > >
> > > > For Each varItem In .ItemsSelected
> > > > strList = strList & .Column(0, varItem) & vbCrLf
> > > > .Selected(varItem) = False 'unselect listbox
> > > >
> > > > Next varItem
> > > > If strList <> "" Then
> > > > strList = Left$(strList, Len(strList) - 1)
> > > > End If
> > > > Me.Employee = strList
> > > > End If
> > > >
> > > > End With
> > > >
> > > > Can anyone help with the code of adding additional employees to the text box
> > > > while keeping any original employees previously selected. Thanks.

 
Reply With Quote
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      1st Aug 2007
I was afraid you would blow the text box size limit with that.
A suform will not allow you to select multiple employee records directly.
You could add a check box to your subform to allow you to select them, but I
don't really understand what it is you are about. All selected items in a
list box show as seleted. Can you give me an idea of the objective, maybe
there is a more simple way to get what you need.
--
Dave Hargis, Microsoft Access MVP


"Michelle" wrote:

> Dave, when I put in the line
>
> Me.MyListBox.ListIndex = -1
>
> I get a runtime error "7777" and the message "you've listed the ListIndex
> property incorrectly". I substituted "Employee" for "MyListBox"??
>
> Anyway, I'm so confused on this multi selection list box. I also found that
> if I select a lot of names, it says my field is too small. I have the field
> set as memo and the field size as 255. Is there a better way to do what I
> want? I've been reading about using a subform but I must be extra blonde
> today because it's just not clicking with me!
>
> My main objective is to select names from "Employees" list box (it's
> actually a table called Hourly Employee Table for Quality Alert) and there
> are 863 names in this table and I would like to be able to highlight from
> 1-863 names if needed. I want to show the selection in another text box,
> combo box, form, or whatever I can, just to show who was selected for each
> record. Any suggestions are appeciated. Thanks.
>
>
>
> "Klatuu" wrote:
>
> > Sorry, Michelle, I misread your post earlier. That was not actually the
> > problem. Now that I examine it a bit closer, I don't see the problem. I am
> > wondering if this
> > line:
> > .Selected(varItem) = False 'unselect listbox
> > Could be the problem. This is not an answer but a suggestion on where to
> > look. In some looping circumstances, when you modify the number of items in
> > the list, it can cause the loop control logic to become confused. In any
> > case, here is a trick for unselecting everything in a list box:
> >
> > Me.MyListBox.ListIndex = -1
> >
> > --
> > Dave Hargis, Microsoft Access MVP
> >
> >
> > "Michelle" wrote:
> >
> > > Dave, I put your code in but it still cleared the previous names out of the
> > > text box. I am curious about your comment "not sure why you need to put
> > > multiple names in one text box" and was wondering if maybe there was a better
> > > way to do what I want?
> > >
> > > I have a list of employees in a table and the user needs to be able to
> > > choose anywhere from 1 to 100 employees that could be associated with a
> > > particular record in my database. It's a training database and we need to
> > > see who is trained in that particular area. The user would like the list of
> > > employees to choose from and would like to highlight each employee and show
> > > what employees were highlighted. They would also like to be able to come
> > > back and add additional employees to the text box. If there is a better way
> > > to do this, I'm open to suggestions. (I didn't explain it clearly, please
> > > let me know). Thanks again for your help.
> > >
> > > "Klatuu" wrote:
> > >
> > > > I assume Me.Employee is the text box, but assuming it is:
> > > > Me.Employee = Me.Employee & ", " & strList
> > > >
> > > > Not sure why you need to put multiple names in one text box, but this will
> > > > do it.
> > > > --
> > > > Dave Hargis, Microsoft Access MVP
> > > >
> > > >
> > > > "Michelle" wrote:
> > > >
> > > > > I have the following code that allows the user to select items in a list box
> > > > > and show them in a text box. However, if the user comes back to a record and
> > > > > wants to add additional names to the text box, it clears out the previous
> > > > > selection.
> > > > >
> > > > > Here is my code:
> > > > >
> > > > > Dim varItem As Variant
> > > > > Dim strList As String
> > > > >
> > > > > With Me.Employee
> > > > > If .MultiSelect = 0 Then
> > > > > Me.Employee = .Value
> > > > > Else
> > > > >
> > > > > For Each varItem In .ItemsSelected
> > > > > strList = strList & .Column(0, varItem) & vbCrLf
> > > > > .Selected(varItem) = False 'unselect listbox
> > > > >
> > > > > Next varItem
> > > > > If strList <> "" Then
> > > > > strList = Left$(strList, Len(strList) - 1)
> > > > > End If
> > > > > Me.Employee = strList
> > > > > End If
> > > > >
> > > > > End With
> > > > >
> > > > > Can anyone help with the code of adding additional employees to the text box
> > > > > while keeping any original employees previously selected. Thanks.

 
Reply With Quote
 
=?Utf-8?B?TWljaGVsbGU=?=
Guest
Posts: n/a
 
      1st Aug 2007
I have a list box on my form that is based on a table of all employee names
(there are 863 employees right now but more will be added in the days to
come). When the user (supervisor) opens an "alert" record they need to be
able to select which employees were trained on that particular "alert".
There are 100s of alerts and each alert will have different employees who are
trained on them. I need a way for the user (supervisor) to select the
employees that are "trained" on each alert, and then need be able to see
which employees the user selected so we know who was trained on each alert
(would like to see the employees in a text box or form). I would then like
to be able to clear out the selections for the next record (or alert) in the
database.

Like I said, any suggestions are welcome.

(It's frustrating, I know what I'm trying to say, but guess I'm not
explaining very well). Thanks again for all your help.



"Klatuu" wrote:

> I was afraid you would blow the text box size limit with that.
> A suform will not allow you to select multiple employee records directly.
> You could add a check box to your subform to allow you to select them, but I
> don't really understand what it is you are about. All selected items in a
> list box show as seleted. Can you give me an idea of the objective, maybe
> there is a more simple way to get what you need.
> --
> Dave Hargis, Microsoft Access MVP
>
>
> "Michelle" wrote:
>
> > Dave, when I put in the line
> >
> > Me.MyListBox.ListIndex = -1
> >
> > I get a runtime error "7777" and the message "you've listed the ListIndex
> > property incorrectly". I substituted "Employee" for "MyListBox"??
> >
> > Anyway, I'm so confused on this multi selection list box. I also found that
> > if I select a lot of names, it says my field is too small. I have the field
> > set as memo and the field size as 255. Is there a better way to do what I
> > want? I've been reading about using a subform but I must be extra blonde
> > today because it's just not clicking with me!
> >
> > My main objective is to select names from "Employees" list box (it's
> > actually a table called Hourly Employee Table for Quality Alert) and there
> > are 863 names in this table and I would like to be able to highlight from
> > 1-863 names if needed. I want to show the selection in another text box,
> > combo box, form, or whatever I can, just to show who was selected for each
> > record. Any suggestions are appeciated. Thanks.
> >
> >
> >
> > "Klatuu" wrote:
> >
> > > Sorry, Michelle, I misread your post earlier. That was not actually the
> > > problem. Now that I examine it a bit closer, I don't see the problem. I am
> > > wondering if this
> > > line:
> > > .Selected(varItem) = False 'unselect listbox
> > > Could be the problem. This is not an answer but a suggestion on where to
> > > look. In some looping circumstances, when you modify the number of items in
> > > the list, it can cause the loop control logic to become confused. In any
> > > case, here is a trick for unselecting everything in a list box:
> > >
> > > Me.MyListBox.ListIndex = -1
> > >
> > > --
> > > Dave Hargis, Microsoft Access MVP
> > >
> > >
> > > "Michelle" wrote:
> > >
> > > > Dave, I put your code in but it still cleared the previous names out of the
> > > > text box. I am curious about your comment "not sure why you need to put
> > > > multiple names in one text box" and was wondering if maybe there was a better
> > > > way to do what I want?
> > > >
> > > > I have a list of employees in a table and the user needs to be able to
> > > > choose anywhere from 1 to 100 employees that could be associated with a
> > > > particular record in my database. It's a training database and we need to
> > > > see who is trained in that particular area. The user would like the list of
> > > > employees to choose from and would like to highlight each employee and show
> > > > what employees were highlighted. They would also like to be able to come
> > > > back and add additional employees to the text box. If there is a better way
> > > > to do this, I'm open to suggestions. (I didn't explain it clearly, please
> > > > let me know). Thanks again for your help.
> > > >
> > > > "Klatuu" wrote:
> > > >
> > > > > I assume Me.Employee is the text box, but assuming it is:
> > > > > Me.Employee = Me.Employee & ", " & strList
> > > > >
> > > > > Not sure why you need to put multiple names in one text box, but this will
> > > > > do it.
> > > > > --
> > > > > Dave Hargis, Microsoft Access MVP
> > > > >
> > > > >
> > > > > "Michelle" wrote:
> > > > >
> > > > > > I have the following code that allows the user to select items in a list box
> > > > > > and show them in a text box. However, if the user comes back to a record and
> > > > > > wants to add additional names to the text box, it clears out the previous
> > > > > > selection.
> > > > > >
> > > > > > Here is my code:
> > > > > >
> > > > > > Dim varItem As Variant
> > > > > > Dim strList As String
> > > > > >
> > > > > > With Me.Employee
> > > > > > If .MultiSelect = 0 Then
> > > > > > Me.Employee = .Value
> > > > > > Else
> > > > > >
> > > > > > For Each varItem In .ItemsSelected
> > > > > > strList = strList & .Column(0, varItem) & vbCrLf
> > > > > > .Selected(varItem) = False 'unselect listbox
> > > > > >
> > > > > > Next varItem
> > > > > > If strList <> "" Then
> > > > > > strList = Left$(strList, Len(strList) - 1)
> > > > > > End If
> > > > > > Me.Employee = strList
> > > > > > End If
> > > > > >
> > > > > > End With
> > > > > >
> > > > > > Can anyone help with the code of adding additional employees to the text box
> > > > > > while keeping any original employees previously selected. Thanks.

 
Reply With Quote
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      1st Aug 2007
With that many employees, you will never be able to see them all at once.
Now, I'm thinking subform. Can you tell me how you identify which employees
have been trained on which alerts?

--
Dave Hargis, Microsoft Access MVP


"Michelle" wrote:

> I have a list box on my form that is based on a table of all employee names
> (there are 863 employees right now but more will be added in the days to
> come). When the user (supervisor) opens an "alert" record they need to be
> able to select which employees were trained on that particular "alert".
> There are 100s of alerts and each alert will have different employees who are
> trained on them. I need a way for the user (supervisor) to select the
> employees that are "trained" on each alert, and then need be able to see
> which employees the user selected so we know who was trained on each alert
> (would like to see the employees in a text box or form). I would then like
> to be able to clear out the selections for the next record (or alert) in the
> database.
>
> Like I said, any suggestions are welcome.
>
> (It's frustrating, I know what I'm trying to say, but guess I'm not
> explaining very well). Thanks again for all your help.
>
>
>
> "Klatuu" wrote:
>
> > I was afraid you would blow the text box size limit with that.
> > A suform will not allow you to select multiple employee records directly.
> > You could add a check box to your subform to allow you to select them, but I
> > don't really understand what it is you are about. All selected items in a
> > list box show as seleted. Can you give me an idea of the objective, maybe
> > there is a more simple way to get what you need.
> > --
> > Dave Hargis, Microsoft Access MVP
> >
> >
> > "Michelle" wrote:
> >
> > > Dave, when I put in the line
> > >
> > > Me.MyListBox.ListIndex = -1
> > >
> > > I get a runtime error "7777" and the message "you've listed the ListIndex
> > > property incorrectly". I substituted "Employee" for "MyListBox"??
> > >
> > > Anyway, I'm so confused on this multi selection list box. I also found that
> > > if I select a lot of names, it says my field is too small. I have the field
> > > set as memo and the field size as 255. Is there a better way to do what I
> > > want? I've been reading about using a subform but I must be extra blonde
> > > today because it's just not clicking with me!
> > >
> > > My main objective is to select names from "Employees" list box (it's
> > > actually a table called Hourly Employee Table for Quality Alert) and there
> > > are 863 names in this table and I would like to be able to highlight from
> > > 1-863 names if needed. I want to show the selection in another text box,
> > > combo box, form, or whatever I can, just to show who was selected for each
> > > record. Any suggestions are appeciated. Thanks.
> > >
> > >
> > >
> > > "Klatuu" wrote:
> > >
> > > > Sorry, Michelle, I misread your post earlier. That was not actually the
> > > > problem. Now that I examine it a bit closer, I don't see the problem. I am
> > > > wondering if this
> > > > line:
> > > > .Selected(varItem) = False 'unselect listbox
> > > > Could be the problem. This is not an answer but a suggestion on where to
> > > > look. In some looping circumstances, when you modify the number of items in
> > > > the list, it can cause the loop control logic to become confused. In any
> > > > case, here is a trick for unselecting everything in a list box:
> > > >
> > > > Me.MyListBox.ListIndex = -1
> > > >
> > > > --
> > > > Dave Hargis, Microsoft Access MVP
> > > >
> > > >
> > > > "Michelle" wrote:
> > > >
> > > > > Dave, I put your code in but it still cleared the previous names out of the
> > > > > text box. I am curious about your comment "not sure why you need to put
> > > > > multiple names in one text box" and was wondering if maybe there was a better
> > > > > way to do what I want?
> > > > >
> > > > > I have a list of employees in a table and the user needs to be able to
> > > > > choose anywhere from 1 to 100 employees that could be associated with a
> > > > > particular record in my database. It's a training database and we need to
> > > > > see who is trained in that particular area. The user would like the list of
> > > > > employees to choose from and would like to highlight each employee and show
> > > > > what employees were highlighted. They would also like to be able to come
> > > > > back and add additional employees to the text box. If there is a better way
> > > > > to do this, I'm open to suggestions. (I didn't explain it clearly, please
> > > > > let me know). Thanks again for your help.
> > > > >
> > > > > "Klatuu" wrote:
> > > > >
> > > > > > I assume Me.Employee is the text box, but assuming it is:
> > > > > > Me.Employee = Me.Employee & ", " & strList
> > > > > >
> > > > > > Not sure why you need to put multiple names in one text box, but this will
> > > > > > do it.
> > > > > > --
> > > > > > Dave Hargis, Microsoft Access MVP
> > > > > >
> > > > > >
> > > > > > "Michelle" wrote:
> > > > > >
> > > > > > > I have the following code that allows the user to select items in a list box
> > > > > > > and show them in a text box. However, if the user comes back to a record and
> > > > > > > wants to add additional names to the text box, it clears out the previous
> > > > > > > selection.
> > > > > > >
> > > > > > > Here is my code:
> > > > > > >
> > > > > > > Dim varItem As Variant
> > > > > > > Dim strList As String
> > > > > > >
> > > > > > > With Me.Employee
> > > > > > > If .MultiSelect = 0 Then
> > > > > > > Me.Employee = .Value
> > > > > > > Else
> > > > > > >
> > > > > > > For Each varItem In .ItemsSelected
> > > > > > > strList = strList & .Column(0, varItem) & vbCrLf
> > > > > > > .Selected(varItem) = False 'unselect listbox
> > > > > > >
> > > > > > > Next varItem
> > > > > > > If strList <> "" Then
> > > > > > > strList = Left$(strList, Len(strList) - 1)
> > > > > > > End If
> > > > > > > Me.Employee = strList
> > > > > > > End If
> > > > > > >
> > > > > > > End With
> > > > > > >
> > > > > > > Can anyone help with the code of adding additional employees to the text box
> > > > > > > while keeping any original employees previously selected. Thanks.

 
Reply With Quote
 
=?Utf-8?B?TWljaGVsbGU=?=
Guest
Posts: n/a
 
      1st Aug 2007
Right now the supervisor checks (or selects) the employees based on his
knowledge. The employees are in a list box called "Employee" based on a
table called "Hourly Employee Table for Quality Alert".


"Klatuu" wrote:

> With that many employees, you will never be able to see them all at once.
> Now, I'm thinking subform. Can you tell me how you identify which employees
> have been trained on which alerts?
>
> --
> Dave Hargis, Microsoft Access MVP
>
>
> "Michelle" wrote:
>
> > I have a list box on my form that is based on a table of all employee names
> > (there are 863 employees right now but more will be added in the days to
> > come). When the user (supervisor) opens an "alert" record they need to be
> > able to select which employees were trained on that particular "alert".
> > There are 100s of alerts and each alert will have different employees who are
> > trained on them. I need a way for the user (supervisor) to select the
> > employees that are "trained" on each alert, and then need be able to see
> > which employees the user selected so we know who was trained on each alert
> > (would like to see the employees in a text box or form). I would then like
> > to be able to clear out the selections for the next record (or alert) in the
> > database.
> >
> > Like I said, any suggestions are welcome.
> >
> > (It's frustrating, I know what I'm trying to say, but guess I'm not
> > explaining very well). Thanks again for all your help.
> >
> >
> >
> > "Klatuu" wrote:
> >
> > > I was afraid you would blow the text box size limit with that.
> > > A suform will not allow you to select multiple employee records directly.
> > > You could add a check box to your subform to allow you to select them, but I
> > > don't really understand what it is you are about. All selected items in a
> > > list box show as seleted. Can you give me an idea of the objective, maybe
> > > there is a more simple way to get what you need.
> > > --
> > > Dave Hargis, Microsoft Access MVP
> > >
> > >
> > > "Michelle" wrote:
> > >
> > > > Dave, when I put in the line
> > > >
> > > > Me.MyListBox.ListIndex = -1
> > > >
> > > > I get a runtime error "7777" and the message "you've listed the ListIndex
> > > > property incorrectly". I substituted "Employee" for "MyListBox"??
> > > >
> > > > Anyway, I'm so confused on this multi selection list box. I also found that
> > > > if I select a lot of names, it says my field is too small. I have the field
> > > > set as memo and the field size as 255. Is there a better way to do what I
> > > > want? I've been reading about using a subform but I must be extra blonde
> > > > today because it's just not clicking with me!
> > > >
> > > > My main objective is to select names from "Employees" list box (it's
> > > > actually a table called Hourly Employee Table for Quality Alert) and there
> > > > are 863 names in this table and I would like to be able to highlight from
> > > > 1-863 names if needed. I want to show the selection in another text box,
> > > > combo box, form, or whatever I can, just to show who was selected for each
> > > > record. Any suggestions are appeciated. Thanks.
> > > >
> > > >
> > > >
> > > > "Klatuu" wrote:
> > > >
> > > > > Sorry, Michelle, I misread your post earlier. That was not actually the
> > > > > problem. Now that I examine it a bit closer, I don't see the problem. I am
> > > > > wondering if this
> > > > > line:
> > > > > .Selected(varItem) = False 'unselect listbox
> > > > > Could be the problem. This is not an answer but a suggestion on where to
> > > > > look. In some looping circumstances, when you modify the number of items in
> > > > > the list, it can cause the loop control logic to become confused. In any
> > > > > case, here is a trick for unselecting everything in a list box:
> > > > >
> > > > > Me.MyListBox.ListIndex = -1
> > > > >
> > > > > --
> > > > > Dave Hargis, Microsoft Access MVP
> > > > >
> > > > >
> > > > > "Michelle" wrote:
> > > > >
> > > > > > Dave, I put your code in but it still cleared the previous names out of the
> > > > > > text box. I am curious about your comment "not sure why you need to put
> > > > > > multiple names in one text box" and was wondering if maybe there was a better
> > > > > > way to do what I want?
> > > > > >
> > > > > > I have a list of employees in a table and the user needs to be able to
> > > > > > choose anywhere from 1 to 100 employees that could be associated with a
> > > > > > particular record in my database. It's a training database and we need to
> > > > > > see who is trained in that particular area. The user would like the list of
> > > > > > employees to choose from and would like to highlight each employee and show
> > > > > > what employees were highlighted. They would also like to be able to come
> > > > > > back and add additional employees to the text box. If there is a better way
> > > > > > to do this, I'm open to suggestions. (I didn't explain it clearly, please
> > > > > > let me know). Thanks again for your help.
> > > > > >
> > > > > > "Klatuu" wrote:
> > > > > >
> > > > > > > I assume Me.Employee is the text box, but assuming it is:
> > > > > > > Me.Employee = Me.Employee & ", " & strList
> > > > > > >
> > > > > > > Not sure why you need to put multiple names in one text box, but this will
> > > > > > > do it.
> > > > > > > --
> > > > > > > Dave Hargis, Microsoft Access MVP
> > > > > > >
> > > > > > >
> > > > > > > "Michelle" wrote:
> > > > > > >
> > > > > > > > I have the following code that allows the user to select items in a list box
> > > > > > > > and show them in a text box. However, if the user comes back to a record and
> > > > > > > > wants to add additional names to the text box, it clears out the previous
> > > > > > > > selection.
> > > > > > > >
> > > > > > > > Here is my code:
> > > > > > > >
> > > > > > > > Dim varItem As Variant
> > > > > > > > Dim strList As String
> > > > > > > >
> > > > > > > > With Me.Employee
> > > > > > > > If .MultiSelect = 0 Then
> > > > > > > > Me.Employee = .Value
> > > > > > > > Else
> > > > > > > >
> > > > > > > > For Each varItem In .ItemsSelected
> > > > > > > > strList = strList & .Column(0, varItem) & vbCrLf
> > > > > > > > .Selected(varItem) = False 'unselect listbox
> > > > > > > >
> > > > > > > > Next varItem
> > > > > > > > If strList <> "" Then
> > > > > > > > strList = Left$(strList, Len(strList) - 1)
> > > > > > > > End If
> > > > > > > > Me.Employee = strList
> > > > > > > > End If
> > > > > > > >
> > > > > > > > End With
> > > > > > > >
> > > > > > > > Can anyone help with the code of adding additional employees to the text box
> > > > > > > > while keeping any original employees previously selected. Thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
multiselect list box SAC Microsoft Access Form Coding 6 28th Dec 2006 01:56 AM
Re: Multiselect List Dirk Goldgar Microsoft Access 0 27th Sep 2005 04:47 PM
Filter a List based on selections from another multiselect list Michael Smith via AccessMonster.com Microsoft Access Forms 0 10th Feb 2005 02:59 PM
List box, multiselect TRM Microsoft Access Form Coding 3 22nd Sep 2004 12:51 PM
Selecting List items in Multiselect list box BobRoyAce Microsoft Access Forms 2 3rd Sep 2004 09:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:17 PM.