View Full Version : Checking field entry
ahassan99
09-17-2012, 04:15 AM
Hi Guys,
Quick one.
Usually the IF statement are with an equal to sign. How do I write it if I need to check if the field CONTAINS something.
Means, if a field contains this word, then do this.
Thanks for your help in advance.
JP2112
09-17-2012, 09:47 AM
You would use the "Instr" Function. Returns > 0 if the needle is found in the haystack.
If Instr("haystack", "needle") > 0 Then ' found it!
' code here
Else ' not found
' code here
End If
ahassan99
09-18-2012, 05:32 AM
Thanks JP,
I am a little confused as to how to use the code.
I have an IF statement to check whether an email address, say abc@xyz.com, is in the to field. I want the condition to be true also even if
any other mail address is written along with it.
My code looks like the below:
If .To = abc@xyz.com Then
BrianMH
09-19-2012, 04:25 AM
If Instr(.To , "abc@xyz.com") > 0 Then ' found it!
' code here
Else ' not found
' code here
End If
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.