I'm trying to setup a simple if then statement that uses a wildcard:
If [SPECIES_CD_2] = "B" Then ** this statement works but
If [SPECIES_CD_2] LIKE "B*" Then ** this statement doesn't
I've tried substituting %, #, & for the asterisk but I keep getting an error (sub or function not defined)
Help!!!
Solved! Go to Solution.
When working in the field calculator, you are either using VBScript or Python, I strongly recommend Python. The LIKE operator you are attempting to use is an SQL function. Python does not have a LIKE string function and I don't believe VBScript does either.
Your syntax indicates you are using VBScript. I believe If LEFT([SPECIES_CD_2],1) = "B" should mimic the LIKE statement you have provided.
When working in the field calculator, you are either using VBScript or Python, I strongly recommend Python. The LIKE operator you are attempting to use is an SQL function. Python does not have a LIKE string function and I don't believe VBScript does either.
Your syntax indicates you are using VBScript. I believe If LEFT([SPECIES_CD_2],1) = "B" should mimic the LIKE statement you have provided.
Quick testing seems to confirm that what you suggest works!
Thank-you Joshua!
If my, or any other, response answers your question, please mark it Correct so others know you already have a workable solution.