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

Removing trailing comma in report field 1

Status
Not open for further replies.

Humlan

Programmer
Nov 14, 2003
18
SE
I'm using a report field with an expression as the "Control Source" so that I can write out the values of several boolean table fields as comma separated text values in one report field. The code looks like this:
Code:
=IIf([Media_Files]="-1";IIf([MF_Music_Files_Bol]="-1";"Music, ";"") & IIf([MF_Movie_Files_Bol]="-1";"Movies, ";"") & IIf([MF_PlayStation_Files_Bol]="-1";"PS, ";"");"")

If a record has the boolean table field "Media_Files" set to True, the report will the list something like "Music, PS,".
Now, this works great, apart from the fact that I always get the trailing comma at the end of the field. I was thinking along the lines of using "Len" plus "Left" or "Right" to remove the last character in the field, but can't seem to figure out how to do this in an expression.

Any ideas?
 
Try this

Code:
=Left(IIf([Media_Files]="-1";IIf([MF_Music_Files_Bol]="-1";"Music, ";"") & IIf([MF_Movie_Files_Bol]="-1";"Movies, ";"") & IIf([MF_PlayStation_Files_Bol]="-1";"PS, ";"");""),Len(=IIf([Media_Files]="-1";IIf([MF_Music_Files_Bol]="-1";"Music, ";"") & IIf([MF_Movie_Files_Bol]="-1";"Movies, ";"") & IIf([MF_PlayStation_Files_Bol]="-1";"PS, ";"");""))-1)

Paul

 
Hmm, thanks for your reply, haven't had time to test this until now.
However it seems that I can't use "Left" in the control source, I get an error saying "The function you entered can't be used in this expression"

I get an error whenever using the Left function, for example:
Code:
=Left("Howdy", 2)
 
Hmm, found out this error seems to pop up for some expressions if a reference is missing. Really cryptic, but here's a thread that pointed me in the right direction: [link]thread181-27567[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top