A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Multi Select List Box to Text Box (put each item on separate line)



 
 
Thread Tools Display Modes
  #1  
Old July 19th, 2007, 09:28 PM posted to microsoft.public.access.forms
michelle
external usenet poster
 
Posts: 818
Default Multi Select List Box to Text Box (put each item on separate line)

Maybe I'm just overlooking the obvious, but is there a way to format the text
in a text box once I've selected it with the following code. (I am putting
the names of employees in a text box to show which employees were selected
for a particular record. The names are appearing in a straight line and
separated by a comma, I would each name to have its own line in the text box.
)

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) & ","
Next varItem
If strList "" Then
strList = Left$(strList, Len(strList) - 1)
End If
Me.Employee = strList
End If

End With

Also, is there a way to "unhighlight" the multi select text box for the
next record (so nothing is highlighted for the next record). I am using a
single form view. Thank you.
  #2  
Old July 20th, 2007, 02:27 AM posted to microsoft.public.access.forms
AccessVandal via AccessMonster.com
external usenet poster
 
Posts: 461
Default Multi Select List Box to Text Box (put each item on separate line)

Hi Michelle,

Just add the line as below.

Michelle wrote:


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

--
Please Rate the posting if helps you

Message posted via http://www.accessmonster.com

  #3  
Old July 20th, 2007, 01:20 PM posted to microsoft.public.access.forms
michelle
external usenet poster
 
Posts: 818
Default Multi Select List Box to Text Box (put each item on separate l

Thanks AccessVandal, that did clear out my selections! Do you know how I
would format the text in the text box once I've selected. (I am putting the
names of employees in a text box to show which employees were selected for a
particular record. The names are appearing in a straight line and
separated by a comma, I would each name to have its own line in the text
box).

Right now my entries are appearing like this in the textbox:

Ex: Adams, Micheal,Adkins, Darla K,Albright, Gayla J

I would like them to appear like this:

Adams, Micheal
Adkins, Darla K
Albright, Gayla

Thanks for your help.



"AccessVandal via AccessMonster.com" wrote:

Hi Michelle,

Just add the line as below.

Michelle wrote:


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

--
Please Rate the posting if helps you

Message posted via http://www.accessmonster.com


  #4  
Old July 20th, 2007, 02:46 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Multi Select List Box to Text Box (put each item on separate l

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

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Michelle" wrote in message
...
Thanks AccessVandal, that did clear out my selections! Do you know how I
would format the text in the text box once I've selected. (I am putting
the
names of employees in a text box to show which employees were selected for
a
particular record. The names are appearing in a straight line and
separated by a comma, I would each name to have its own line in the text
box).

Right now my entries are appearing like this in the textbox:

Ex: Adams, Micheal,Adkins, Darla K,Albright, Gayla J

I would like them to appear like this:

Adams, Micheal
Adkins, Darla K
Albright, Gayla

Thanks for your help.



"AccessVandal via AccessMonster.com" wrote:

Hi Michelle,

Just add the line as below.

Michelle wrote:


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

--
Please Rate the posting if helps you

Message posted via http://www.accessmonster.com




  #5  
Old July 20th, 2007, 07:44 PM posted to microsoft.public.access.forms
michelle
external usenet poster
 
Posts: 818
Default Multi Select List Box to Text Box (put each item on separate l

Thanks to both Doug and AccessVandal, this worked perfectly!

"Douglas J. Steele" wrote:

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

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Michelle" wrote in message
...
Thanks AccessVandal, that did clear out my selections! Do you know how I
would format the text in the text box once I've selected. (I am putting
the
names of employees in a text box to show which employees were selected for
a
particular record. The names are appearing in a straight line and
separated by a comma, I would each name to have its own line in the text
box).

Right now my entries are appearing like this in the textbox:

Ex: Adams, Micheal,Adkins, Darla K,Albright, Gayla J

I would like them to appear like this:

Adams, Micheal
Adkins, Darla K
Albright, Gayla

Thanks for your help.



"AccessVandal via AccessMonster.com" wrote:

Hi Michelle,

Just add the line as below.

Michelle wrote:

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

--
Please Rate the posting if helps you

Message posted via http://www.accessmonster.com





 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:18 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.