IF statement with empty text field won't work

S

sejtraav

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!
 
D

Doug Robbins - Word MVP

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
 
G

Graham Mayor

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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