Hi,
I would like to know how to write if statements that includes "wildcards" for spaces. For example:
my problem is that if rs!Revision = "L" and Me.txtRev = "L " then the program would think that those two are not alike because of the space after the "L " in Me.txtRev and therefore it goes though the loop when I don't want it to.Code:If rs!Revision <> Me.txtRev Then ' do something here End if
Is there a way to have it something like this (I tried the code below and i know it doesn't work):
There is something wrong with this part of the code: " * & me.txtRev & * " and I don't know how to fix it.Code:If rs!Revision <> " * & me.txtRev & * " then ' do something here End if
Please help.
Thanks!
Last edited by tnguyen; 12-02-2009 at 05:12 PM.
You're close with the wild cards - it's your quotes that are throwing it off. And the use of the Like operator is correct too.
Code:'This will find '*L*' (L anywhere in me.txtRev) If rs!Revision Like "*" & me.txtRev & "*" then ' do something here End if 'This will find 'L*' (L at the start of me.txtRev) If rs!Revision Like me.txtRev & "*" then ' do something here End if 'This will find '*L' (L at the end of me.txtRev) If rs!Revision Like "*" & me.txtRev then ' do something here End if
Thanks! That works.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks