coconutt said:
I have a macro
Sub Save2()
Dim vRefferingPhysician, vDate As String
If vRefferingPhysician = "Swain"
Then
Save
Else
SaveR
End If
End Sub
when I run the code it will always run the saveR macro, even if the
field is swain am I asking the right if question?
Thanks
Hi coconutt,
The question is OK (almost) but you've neglected to give the variable
vRefferingPhysician any value, so the comparison can never be true.
What is "the field"? If it's a text form field in a protected form, use the
name assigned to it in the field's Properties dialog to do something like
this before the If statement:
vRefferingPhysician = _
ActiveDocument.FormFields("RefferingPhysician").Result
The "almost" part is that the comparison is case-sensitive, so you probably
should do this instead:
If LCase(vRefferingPhysician) = "swain"
One more bit, not critical but a bad habit: By omitting the "As" clause for
vRefferingPhysician in your Dim statement, you've implicitly declared it as
Variant data type, not String. Each variable in a Dim statement needs its
own As clause. It should be
Dim vRefferingPhysician As String, vDate As String
(And what is vDate? you don't use it.)
Lastly, my sensibility is offended by the misspelling of 'referring'. ;-)