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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strip data from Concatenated string 1

Status
Not open for further replies.

jonohara999

Technical User
Joined
Nov 4, 2008
Messages
3
Location
GB
HI There

I've used the concatenate code, from the FAQ in this forum, to create a string of related products on my shopping cart. This works well, but i'd like to strip out one of the values in the string which is a duplicate. So i currently return data like this...

productid related productids (concatenated)
1 1,2,3,4,5
2 1,2,3,4,5
3 1,2,3,4,5
etc

and i'd like data like this...

productid related products
1 2,3,4,5
2 1,3,4,5
3 1,2,4,5
etc

Is that possible?

Thanks

Jon
 
Replace may suit:

Replace([Related ProductIDs],[ProductID] & ",","")
Replace([Related ProductIDs],[ProductID],"")

Or you may wish to modify the concatenation code to skip the value of [productid].
 
You could modify the SQL statement in the function to not include the ProductID of the current record. If you post the SQL, someone could provide more specific assistance.
Code:
Concatenate("SELECT ProductID FROM tblProducts WHERE ProdCatID = " & ProdCatID & " AND ProductID <>" & ProductID & " ORDER BY ProductID")

Duane
Hook'D on Access
MS Access MVP
 
Thanks that's great. The sql i'm currently using is

Code:
Concatenate("SELECT intcatalogid FROM tblsofabedsCONCAT WHERE categoryidsb =" & [categoryidsb]) AS relatedproducts
FROM tblSofaBedsCONCAT;

Where intcatalogid is the 'productid'

Jon
 
Try the following which assumes intcatalogid is numeric:
Code:
Concatenate("SELECT intcatalogid FROM tblsofabedsCONCAT WHERE categoryidsb =" & [categoryidsb] & " AND intcatalogid <> " & intcatalogid) AS relatedproducts
FROM tblSofaBedsCONCAT;

Duane
Hook'D on Access
MS Access MVP
 
Fantastic thanks very much for all your help.

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top