Strip trailing characters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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)
 
Back
Top