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  

Break between ItemSelected from List Box



 
 
Thread Tools Display Modes
  #1  
Old December 31st, 2009, 05:59 PM posted to microsoft.public.access.forms
Pamela
external usenet poster
 
Posts: 193
Default Break between ItemSelected from List Box

I have a text box that takes the entries from a multi-select list box and
concatenates them. My code is not reading that there is supposed to be a
comma and space between each of the selected items from my list box. My code
currently lists them correctly but all together but running into each other
with no spaces. I believe the problem lies in line 5 where "strText" is. We
tried setting it to varRow but that just lists the # of items selected. Here
is my code:
Dim varRow As Variant, strText As String
'strText = vbNullString
For Each varRow In Me.lbDamagedParts.ItemsSelected
strText = strText & Me.lbDamagedParts.Column(0, varRow)
Me.Text39 = "The vehicle sustained damage to the " & strText & ", "
Next varRow
Me.Text39 = Left(Me.Text39, Len(Me.Text39) - 1) & "."

Thank you so much!

Pamela
  #2  
Old December 31st, 2009, 06:28 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Break between ItemSelected from List Box

Dim varRow As Variant, strText As String

strText = vbNullString
If Me.lbDamagedParts.ItemsSelected.Count 0 Then
For Each varRow In Me.lbDamagedParts.ItemsSelected
strText = strText & Me.lbDamagedParts.Column(0, varRow) & ", "
Next varRow
Me.Text39 = "The vehicle sustained damage to the " & _
Left(strText, Len(strText) - 2) & "."
Else
Me.Text39 = "The vehicle did not sustain any damage."
End If

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


"Pamela" wrote in message
...
I have a text box that takes the entries from a multi-select list box and
concatenates them. My code is not reading that there is supposed to be a
comma and space between each of the selected items from my list box. My
code
currently lists them correctly but all together but running into each
other
with no spaces. I believe the problem lies in line 5 where "strText" is.
We
tried setting it to varRow but that just lists the # of items selected.
Here
is my code:
Dim varRow As Variant, strText As String
'strText = vbNullString
For Each varRow In Me.lbDamagedParts.ItemsSelected
strText = strText & Me.lbDamagedParts.Column(0, varRow)
Me.Text39 = "The vehicle sustained damage to the " & strText & ", "
Next varRow
Me.Text39 = Left(Me.Text39, Len(Me.Text39) - 1) & "."

Thank you so much!

Pamela



  #3  
Old December 31st, 2009, 07:01 PM posted to microsoft.public.access.forms
Tom Wickerath
external usenet poster
 
Posts: 3,914
Default Break between ItemSelected from List Box

Hi Pamela,

Did you see this reply, which I just posted in the wee hours of this morning?

http://www.microsoft.com/office/comm...e78&sloc=en-us

(I had forgotten to come back to this group to check for replies, and the
notification service is still not working, after several months, when one
posts via the web as both of us have done).


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________

"Pamela" wrote:

I have a text box that takes the entries from a multi-select list box and
concatenates them. My code is not reading that there is supposed to be a
comma and space between each of the selected items from my list box. My code
currently lists them correctly but all together but running into each other
with no spaces. I believe the problem lies in line 5 where "strText" is. We
tried setting it to varRow but that just lists the # of items selected. Here
is my code:
Dim varRow As Variant, strText As String
'strText = vbNullString
For Each varRow In Me.lbDamagedParts.ItemsSelected
strText = strText & Me.lbDamagedParts.Column(0, varRow)
Me.Text39 = "The vehicle sustained damage to the " & strText & ", "
Next varRow
Me.Text39 = Left(Me.Text39, Len(Me.Text39) - 1) & "."

Thank you so much!

Pamela

  #4  
Old December 31st, 2009, 07:17 PM posted to microsoft.public.access.forms
Pamela
external usenet poster
 
Posts: 193
Default Break between ItemSelected from List Box

Thank you, Thank you, Thank you! I've been struggling with this aspect for 3
days and Poof! it's fixed - and working beautifully! I really appreciate
your time and help in this and all of those out there that have spent time
helping me on this project!

Pamela

"Douglas J. Steele" wrote:

Dim varRow As Variant, strText As String

strText = vbNullString
If Me.lbDamagedParts.ItemsSelected.Count 0 Then
For Each varRow In Me.lbDamagedParts.ItemsSelected
strText = strText & Me.lbDamagedParts.Column(0, varRow) & ", "
Next varRow
Me.Text39 = "The vehicle sustained damage to the " & _
Left(strText, Len(strText) - 2) & "."
Else
Me.Text39 = "The vehicle did not sustain any damage."
End If

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


"Pamela" wrote in message
...
I have a text box that takes the entries from a multi-select list box and
concatenates them. My code is not reading that there is supposed to be a
comma and space between each of the selected items from my list box. My
code
currently lists them correctly but all together but running into each
other
with no spaces. I believe the problem lies in line 5 where "strText" is.
We
tried setting it to varRow but that just lists the # of items selected.
Here
is my code:
Dim varRow As Variant, strText As String
'strText = vbNullString
For Each varRow In Me.lbDamagedParts.ItemsSelected
strText = strText & Me.lbDamagedParts.Column(0, varRow)
Me.Text39 = "The vehicle sustained damage to the " & strText & ", "
Next varRow
Me.Text39 = Left(Me.Text39, Len(Me.Text39) - 1) & "."

Thank you so much!

Pamela



.

  #5  
Old January 15th, 2010, 02:46 AM posted to microsoft.public.access.forms
Pamela
external usenet poster
 
Posts: 193
Default Break between ItemSelected from List Box

Hi Doug,

I was so excited when you gave me this code and it worked just perfectly. I
decided to try to make the form more user-friendly and filtered the listbox
items by another cbo on the form. I thought I had it nailed today but when I
tested it, all of a sudden, the items selected aren't showing up from your
code here. Instead, I am getting, "The vehicle sustained damage to the , , ,
, ,." Any ideas why the code that worked so beautifully before would stop
reading the variable just because the box is now filtered? And note, that it
isn't taking the "Else" case should there be no selection, so it's reading
that there is a selection and even reading the correct # of commas - but not
the text itself. Thank you so very much for any help you can give me on
this!!

Pamela

"Douglas J. Steele" wrote:

Dim varRow As Variant, strText As String

strText = vbNullString
If Me.lbDamagedParts.ItemsSelected.Count 0 Then
For Each varRow In Me.lbDamagedParts.ItemsSelected
strText = strText & Me.lbDamagedParts.Column(0, varRow) & ", "
Next varRow
Me.Text39 = "The vehicle sustained damage to the " & _
Left(strText, Len(strText) - 2) & "."
Else
Me.Text39 = "The vehicle did not sustain any damage."
End If

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


"Pamela" wrote in message
...
I have a text box that takes the entries from a multi-select list box and
concatenates them. My code is not reading that there is supposed to be a
comma and space between each of the selected items from my list box. My
code
currently lists them correctly but all together but running into each
other
with no spaces. I believe the problem lies in line 5 where "strText" is.
We
tried setting it to varRow but that just lists the # of items selected.
Here
is my code:
Dim varRow As Variant, strText As String
'strText = vbNullString
For Each varRow In Me.lbDamagedParts.ItemsSelected
strText = strText & Me.lbDamagedParts.Column(0, varRow)
Me.Text39 = "The vehicle sustained damage to the " & strText & ", "
Next varRow
Me.Text39 = Left(Me.Text39, Len(Me.Text39) - 1) & "."

Thank you so much!

Pamela



.

  #6  
Old January 15th, 2010, 12:39 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Break between ItemSelected from List Box

Did you change what order the fields are in the list box? Remember that the
code is supposed to be grabbing whatever's in the first column of each of
the selected rows.

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

"Pamela" wrote in message
...
Hi Doug,

I was so excited when you gave me this code and it worked just perfectly.
I
decided to try to make the form more user-friendly and filtered the
listbox
items by another cbo on the form. I thought I had it nailed today but
when I
tested it, all of a sudden, the items selected aren't showing up from your
code here. Instead, I am getting, "The vehicle sustained damage to the ,
, ,
, ,." Any ideas why the code that worked so beautifully before would stop
reading the variable just because the box is now filtered? And note, that
it
isn't taking the "Else" case should there be no selection, so it's reading
that there is a selection and even reading the correct # of commas - but
not
the text itself. Thank you so very much for any help you can give me on
this!!

Pamela

"Douglas J. Steele" wrote:

Dim varRow As Variant, strText As String

strText = vbNullString
If Me.lbDamagedParts.ItemsSelected.Count 0 Then
For Each varRow In Me.lbDamagedParts.ItemsSelected
strText = strText & Me.lbDamagedParts.Column(0, varRow) & ", "
Next varRow
Me.Text39 = "The vehicle sustained damage to the " & _
Left(strText, Len(strText) - 2) & "."
Else
Me.Text39 = "The vehicle did not sustain any damage."
End If

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


"Pamela" wrote in message
...
I have a text box that takes the entries from a multi-select list box
and
concatenates them. My code is not reading that there is supposed to be
a
comma and space between each of the selected items from my list box.
My
code
currently lists them correctly but all together but running into each
other
with no spaces. I believe the problem lies in line 5 where "strText"
is.
We
tried setting it to varRow but that just lists the # of items selected.
Here
is my code:
Dim varRow As Variant, strText As String
'strText = vbNullString
For Each varRow In Me.lbDamagedParts.ItemsSelected
strText = strText & Me.lbDamagedParts.Column(0, varRow)
Me.Text39 = "The vehicle sustained damage to the " & strText & ", "
Next varRow
Me.Text39 = Left(Me.Text39, Len(Me.Text39) - 1) & "."

Thank you so much!

Pamela



.



  #7  
Old January 15th, 2010, 02:45 PM posted to microsoft.public.access.forms
Pamela
external usenet poster
 
Posts: 193
Default Break between ItemSelected from List Box

When staring at your code, I remembered something I had read about the Column
function which triggered the possibility that maybe the column count had
changed. I added back the ID to the list box query and it worked again.
Thanks so much!

"Pamela" wrote:

I have a text box that takes the entries from a multi-select list box and
concatenates them. My code is not reading that there is supposed to be a
comma and space between each of the selected items from my list box. My code
currently lists them correctly but all together but running into each other
with no spaces. I believe the problem lies in line 5 where "strText" is. We
tried setting it to varRow but that just lists the # of items selected. Here
is my code:
Dim varRow As Variant, strText As String
'strText = vbNullString
For Each varRow In Me.lbDamagedParts.ItemsSelected
strText = strText & Me.lbDamagedParts.Column(0, varRow)
Me.Text39 = "The vehicle sustained damage to the " & strText & ", "
Next varRow
Me.Text39 = Left(Me.Text39, Len(Me.Text39) - 1) & "."

Thank you so much!

Pamela

 




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 01:36 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.