UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> "Not Like" operator in VBA    
 
   
WongMeister
post Sep 20 2007, 07:32 PM
Post #1

UtterAccess Ruler
Posts: 1,509
From: Redondo Beach, CA



I'm taking my first stab in creating a complex function.

In this part of the code, I have:

If Mid(Mod1, 1, 1) Like "[A-Z]" Then....

But if I want this to change to the exclusion, I get an error message:

If Mid(Mod1, 1, 1) Not Like "[A-Z]" Then...

Does the word "Not" not work when creating a vba function?
Go to the top of the page
 
+
JeffK
post Sep 20 2007, 08:21 PM
Post #2

UtterAccess VIP
Posts: 1,536
From: Lansing, MI



You have to do it a bit differently in VBA than in SQL. VBA recognizes Like as an operator but you have to negate the whole expression rather than the operator.

For example, change this:
If Mid(Mod1, 1, 1) Not Like "[A-Z]" Then...

To this:
If Not (Mid(Mod1, 1, 1) Like "[A-Z]") Then...

Note the placement of the Not operator before the entire Like comparison.

HTH
Jeff
Go to the top of the page
 
+
WongMeister
post Sep 20 2007, 08:30 PM
Post #3

UtterAccess Ruler
Posts: 1,509
From: Redondo Beach, CA



Thanks Jeff!

As my short-term memory begins to fade in my adult life, I find it more difficult to remember the specific nuances betwen SQL and VBA...

Thanks again,
Rich
Go to the top of the page
 
+
JeffK
post Sep 20 2007, 08:43 PM
Post #4

UtterAccess VIP
Posts: 1,536
From: Lansing, MI



Happy to help. Good luck with the rest of your "first stab"! (IMG:http://www.utteraccess.com/forum/style_emoticons/default/sad.gif)
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 08:06 PM

Tag cloud: