Wildcard Follow

0
Avatar
Legacy Poster

Hi

 

I have a label that uses layers and there are conditions as to when a layer should print.  But I am finding that maintaining the layers is becoming an issue.  I would much rather have a VB Script in the "OnNewRecord" to control the visibility of the fields.

 

However a couple of the conditions use "contains" or "does not contain"... is there a vbfunction/operator that I can use?  Does Bartender allow wildcards?  

 

Basically I need to be able to say "If the field contains "*MTHS" or "* YRS" then make Text 22 visible.  But if the field contains "*MONTHS" or "*YEARS" make Text 25 visible. 

 

There are other conditions but those are definite ones....

 

Any help or guidance would be appreciated.

 

Thanks

 

Nicky

3 comments

0
Avatar
Legacy Poster
Comment actions Permalink

To do this I normally use the "InStr()" VB function.

 

http://msdn.microsoft.com/en-us/library/8460tsh1

 

Format can be used like:

if (InStr(data, "ABC") > 0) then
...
end if

if the "ABC" is found inside data, then the InStr will return greater than 0. If it is not found, it will return 0.

0
Avatar
Legacy Poster
Comment actions Permalink

Hi 

 

Thank you so much for your help... it worked.  

 

I do have another question which I am hoping you can help me with.

 

I now have to add a condition to evaluate if another field is blank.  I have tried both IsNull and IsEmpty.  I know for with complete certainty that the field is blank... there is nothing.  I have tried:

 

If (InStr(SD1, "ABC") > 0) and IsEmpty(SD3) then

 

but it just wont evaluate the IsEmpty?

 

Any idea what I am doing wrong.

 

Thanks.

Nicky

0
Avatar
Fernando Ramos Miracle
Moderator
Comment actions Permalink

Hello NickySA,

 

I would first recommend trying the "IsEmpty()" condition by itself to see if it really is not working.

 

Also please make sure that the field is truly empty (no space characters for example).

 

Another possibility to test if a field is empty is to compare it with [""]:

 

 

If SD1 = "" Then
...
End If
 

 

Also, please make sure to properly reference named data sources and database fields:

 

- Field("<DatabaseName>.<FieldName>")

- Format.NamedSubStrings("<DataSourceName").Value 

 

You can load their value on a variable if it's too cumbersome to use the full reference each time.

 

Finally, you can try adding a "MsgBox()" command before the actual "If" statements to get a prompt of the value you are trying to verify. This can help you find where the problem might be:

 

 

MsgBox(SD1)
If SD1 = "" Then
...
End If
 

 

Regards

Please sign in to leave a comment.