Re: Check last character

Tech-Archive recommends: Fix windows errors by optimizing your registry



I am assuming that you are checking the last character of the docVariable
value. Something like this:
Sub Test()
Dim strName As String
ActiveDocument.Variables("EElName").Value = "Miller" 'added for testing
strName = ActiveDocument.Variables("EElName").Value
If Right(strName, 1) = "s" Then
strName = strName & "'"
Else
strName = strName & "'s"
End If
MsgBox strName
End Sub

You could just as easily check the Userform textbox for this condition and
make the change before writing its result to the docvariable.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kevin R wrote:
I have a docvariable - { DOCVARIABLE "EELName" } - that pulls an
employees last name from a user form. I need to be able to check the
last character of that name to see if it is an "s" or not. If so,
then I will need to add just an apostrophe. If it is not an "s" then
I will need to add an apostrophe followed by s, ex: 's. Any ideas?


.



Relevant Pages

  • Re: Referencing subform during module code
    ... This would work at the form level, but not at the subform. ... Dim strName As String ...
    (comp.databases.ms-access)
  • Re: INSERT INTO statement
    ... Dim StrSQL as String ... Dim strName As String ... O Wilson wrote: ...
    (microsoft.public.access.gettingstarted)
  • Re: INSERT INTO statement
    ... get treated as if it were a division problem. ... Dim StrSQL as String ... Dim strName As String ...
    (microsoft.public.access.gettingstarted)
  • Re: Renaming documents from text within the document using existin
    ... Actually the numbers should be 7 and 7 to ignore the space character after ... StrName = ActiveDocument.Paragraphs.Range.Text ... character was found because you did trim off the first six characters. ... You can use the replace command to remove tab characters from a string and I ...
    (microsoft.public.word.vba.general)
  • Re: Renaming documents from text within the document using existin
    ... StrName = ActiveDocument.Paragraphs.Range.Text ... character was found because you did trim off the first six characters. ... You can use the replace command to remove tab characters from a string and I ...
    (microsoft.public.word.vba.general)