Strip trailing characters

N

Ned

Hi,

I will highly appreciate if you can help me with this :

In my access 2000 form's text box I have a string ending with comas like this

"Mystring, my string, my string,"
or
"my string,,,"
or
"my string, mystring,,""

My concern is to get rid of comas at the very end of sentences by writing a
function.

Is this possible?

Thanks in advance

Ned
 
K

Ken Snell [MVP]

You could use a function similar to this:

Public Function StripTrailingCommas(strOriginalString As String) As String
StripTrailingCommas = strOriginalString
Do While Right(StripTrailingCommas, 1) = ","
StripTrailingCommas = Left(StripTrailingCommas,
Len(StripTrailingCommas) - 1)
Loop
End Function

Put this function in a regular module and then call it from your code.

Me.txtBoxName.Value = StripTrailingCommas(Me.txtBoxName.Value)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top