Punctuation, baby

twoplustwo

Registered User.
Local time
Today, 14:59
Joined
Oct 31, 2007
Messages
507
Hey guys,

I think I've seen a solution to this here before but I can't really word my problem into a search criteria!

I basically group some sites in a module into one string. I separate these with commas presently but I can't figure out how to stop before the last entry.

Code:
For x = 0 To lstSite.ListCount - 1 'Select sites
    If lstSite.Selected(x) = True Then
    [b]   strSite = strSite & lstSite.Column(2, x) & ", "[/b]
    End If
Next

Bolded is the line I need to edit I guess.

Please to be suggesting how to go about it :)

Thanks.

Steve.
 
The elegant solution is to add the first site with no comma then put the comma in front of the site string in the loop. The quick and dirty way is to crop two chars off the string after the loop has ended.
 
Hi ds,

Thanks for the ideas.

Would it be possible to point me in the right direction or offer some syntaxt advice?

Thanks for the reply.
 
I am the worlds worst at actual coding. Just plug away till the damn thing works, mainly because I have used to many different pieces of software. Anyway try this
strSite = Left(strSite, Len(strSite - 2))
which should chop off the final comma and space
 
Hmm I've inserted that but it "can't assign to this expression"...

Code:
For x = 0 To lstSiteContact.ListCount - 1 'Select sites
    If lstSiteContact.Selected(x) = True Then
       strCc = strCc & lstSiteContact.Column(1, x) & ", "
       [b]strCc = Right(strCc, Len(strCc - 2))[/b]
    End If
Next

It breaks at the bolded line :)
 
Sorry, It must go outside the loop
For x = 0 To lstSiteContact.ListCount - 1 'Select sites
If lstSiteContact.Selected(x) = True Then
strCc = strCc & lstSiteContact.Column(1, x) & ", "
End If
Next
strCc = Left(strCc, Len(strCc - 2))
 
Thanks for the reply.

It's getting errored I think because we're trying to use a numeric expression on a string according to Access Help.

"You attempted to use a numeric expression as an argument to the Len function.
The Len function doesn't accept a numeric expression, a numeric literal, or a binary numeric expression, but it does accept either a string or numeric variable, a string expression, or a variable of user-defined type."
 

Users who are viewing this thread

Back
Top Bottom