Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2006

Tip: Looking for answers? Try searching our database.

IF statement with empty text field won't work

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sejtraav - 09 Sep 2006 14:19 GMT
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!
Doug Robbins - Word MVP - 09 Sep 2006 15:13 GMT
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

Signature

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

> I'm working on a document and want this to happen:
> Document asks "Username?" using the ASK field.
[quoted text clipped - 10 lines]
>
> Any help will be much apreciated!
Graham Mayor - 09 Sep 2006 15:24 GMT
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 }" }

Signature

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

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

> I'm working on a document and want this to happen:
> Document asks "Username?" using the ASK field.
[quoted text clipped - 8 lines]
>
> Any help will be much apreciated!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.