Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenate in a loop 1

Status
Not open for further replies.

d222222

Programmer
Jun 12, 2007
34
US
I need to concatenate a value for each time it goes through the loop. This loop is used to pass the values to the database and that part works (the Call AddEquipUsers) but then I want to take the "sEquipUserName" and create a list that is comma deliminated. I'm going to pass it into a new value called "sDesktopUserList" but I can't get the code right.

Code:
For Each Field In Request.Form
  If InStr(Field,"D_")>0 Then
	id = Mid(Field,3)		
    	sEquipUserName = Trim(Request.Form("D_" & id))
	If sEquipUserName <> "" Then
	      Call AddEquipUsers(sEquipReqNbr, sEquipTypeNbr, sEquipUserName) 
	      sDesktopUserList = sEquipUserName
	      sDesktopUserList = sDesktopUserList & ", " & sDesktopUserList
	Else
	End If
End If
Next

Can anyone tell me what I am doing wrong?
 
[tt][blue]sDesktopUserList=""[/blue]
For Each Field In Request.Form
If InStr(Field,"D_")>0 Then
id = Mid(Field,3)
sEquipUserName = Trim(Request.Form("D_" & id))
If sEquipUserName <> "" Then
Call AddEquipUsers(sEquipReqNbr, sEquipTypeNbr, sEquipUserName)
[red]'[/red]sDesktopUserList = sEquipUserName
[blue]sDesktopUserList = sDesktopUserList & sEquipUserName & ", "[/blue]
Else
End If
End If
Next
[blue]if len(sDesktopUserList)<>0 then
sDesktopUserList=left(sDesktopUserList,len(sDesktopUserList)-2)
end if[/blue]
[/tt]
 
Thank you very much! I could get it close but I always had an extra comma at the beginning or end and you covered all of the bases!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top