Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-13-2020, 01:52 PM
evilside evilside is offline Test Field Contents Windows 10 Test Field Contents Office 2016
Novice
Test Field Contents
 
Join Date: Nov 2020
Posts: 3
evilside is on a distinguished road
Default Test Field Contents

Hi




I have a "partial" solution to compare text Form Field empty content, the trick is compare to six ? wildcards and one * wildcard:

{IF {textFormFieldName} = "??????*" "Field is not empty" "Field is empty"}

The problem is it only detect string with six characters minimum.
Reply With Quote
  #2  
Old 11-13-2020, 02:08 PM
macropod's Avatar
macropod macropod is offline Test Field Contents Windows 10 Test Field Contents Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The behaviour is by design - each '?' represent exactly one character, but the '*' represents any number of characters. The question is why are you using such a construction to test whether a field is empty, when that should be done with code like:
Field is {IF{REF textFormFieldName}<> " " "not "}empty
A field that contains at least six characters cannot be empty...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-13-2020, 02:27 PM
evilside evilside is offline Test Field Contents Windows 10 Test Field Contents Office 2016
Novice
Test Field Contents
 
Join Date: Nov 2020
Posts: 3
evilside is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
The behaviour is by design - each '?' represent exactly one character, but the '*' represents any number of characters. The question is why are you using such a construction to test whether a field is empty, when that should be done with code like:
Field is {IF{REF textFormFieldName}<> " " "not "}empty
A field that contains at least six characters cannot be empty...

Easy, because:


{IF{REF textFormFieldName}<> "" "not "}


...not working. That is the origin of this thread. This trick was useful in my case.
Reply With Quote
  #4  
Old 11-13-2020, 02:38 PM
macropod's Avatar
macropod macropod is offline Test Field Contents Windows 10 Test Field Contents Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Unless you've changed the defaults, an 'empty' text formfield will have exactly 5 spaces - it cannot have 6 or more characters. Hence, to test whether a text formfield is 'empty', you'd use:
Code:
Field is {IF{REF textFormFieldName}<> "     " "not "}empty
Of course, then you have the problem of what to do if the user has simply pressed the spacebar one or more times and ended up with anything other than 5 spaces (e.g. 100) in the formfield...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 11-16-2020, 06:43 AM
evilside evilside is offline Test Field Contents Windows 10 Test Field Contents Office 2016
Novice
Test Field Contents
 
Join Date: Nov 2020
Posts: 3
evilside is on a distinguished road
Default

Excellent! That is most precisely.

Although this behavior is evidently a Word bug.

Thanks.
Reply With Quote
  #6  
Old 11-16-2020, 12:26 PM
macropod's Avatar
macropod macropod is offline Test Field Contents Windows 10 Test Field Contents Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

No, it is not a Word bug. Doubtless, the behaviour was originally documented - Word formfields have performed this way for decades.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Student's t-test (T.TEST): how to get p value? seanspotatobusiness Excel 1 07-20-2018 05:46 AM
Test Field Contents Include Table of Contents by Mail Merge Field vandelayindies Mail Merge 1 01-08-2018 03:06 PM
Contents Page Field Formatting hdmackay Word 17 01-12-2017 01:44 PM
Test Field Contents Table of contents not displaying custom text in field wrdy Word 3 01-05-2015 02:57 AM
unable to send test message Please verify the email address field jarv Outlook 0 04-30-2010 07:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft