I'm working on a document and want this to happen:
Document asks "Username?" using the ASK field.
If something is typed in, i want it to display Username: and then the
persons username, but if nothing is typed in the box, i want it not to show
anything, not even the "Username:" label. Word is seeming to have trouble
with the 'nothing' part of this. Here is what i've tried which hasnt seemed
to work:

{ ASK user "Username:" }
{ IF user = "" " " "Username:{user}" }

Any help will be much apreciated!

Re: IF statement with empty text field won't work by Doug

Doug
Sat Sep 09 09:13:59 CDT 2006

As you have posted to a VBA newsgroup, I would suggest that you use an
InputBox and insert a bookmark named user where you want the name to appear.

Dim User as String
User = InputBox("Enter your name.")
ActiveDocument.Bookmarks("user").Range.InsertBefore User



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"sejtraav" <sejtraav@discussions.microsoft.com> wrote in message
news:91F9C4F9-F149-4040-A416-7AE0725E7979@microsoft.com...
> I'm working on a document and want this to happen:
> Document asks "Username?" using the ASK field.
> If something is typed in, i want it to display Username: and then the
> persons username, but if nothing is typed in the box, i want it not to
> show
> anything, not even the "Username:" label. Word is seeming to have trouble
> with the 'nothing' part of this. Here is what i've tried which hasnt
> seemed
> to work:
>
> { ASK user "Username:" }
> { IF user = "" " " "Username:{user}" }
>
> Any help will be much apreciated!



Re: IF statement with empty text field won't work by Graham

Graham
Sat Sep 09 09:24:27 CDT 2006

Word isn't having trouble! It's you that has the syntax wrong. Try

{ IF { User } = "Error!*" "" "Username : {user }" }
or
{ IF { User }<> "Error!*" "Username : {user }" }


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

sejtraav wrote:
> I'm working on a document and want this to happen:
> Document asks "Username?" using the ASK field.
> If something is typed in, i want it to display Username: and then the
> persons username, but if nothing is typed in the box, i want it not
> to show anything, not even the "Username:" label. Word is seeming to
> have trouble with the 'nothing' part of this. Here is what i've tried
> which hasnt seemed to work:
>
> { ASK user "Username:" }
> { IF user = "" " " "Username:{user}" }
>
> Any help will be much apreciated!