Not Like Operator (Access 2000)

mous

Registered User.
Local time
Today, 11:09
Joined
Sep 26, 2001
Messages
109
I have some code where the <> Operator is not working. I've not noticed this in the past, and I've not altered anything.

If [Counter].Value = 0 And [DLHours]> [CLHour] And [Title] <> "NVQ*" And [LoadBandYN] = "N" And [Value1] > [Value2] Then
<peformsomething>
End If

How can I rearrange this to work correctly.

Thanks for any help.
 
neileg said:
Could you use Left([Title],3) <> "NVQ"
Nope, this has the same effect. Surely, this is a standard operator that can be performed.

Regards
 
[Title] Not Like "NVQ*"


Neileg's should work though; maybe you just didn't implement it correctly.
 
This still doesn't work. I'm getting a compile error, expected expression.

Thanks
 
mous said:
This still doesn't work. I'm getting a compile error, expected expression.
Then it's not the <> operator. Have you tried sticking some parentheses in there in case the statement is not being parsed correctly? Perhaps like this:

If ([Counter].Value = 0) And ([DLHours]> [CLHour]) And ([Title] <> "NVQ*") And ([LoadBandYN] = "N") And ([Value1] > [Value2]) Then
<peformsomething>
End If
 
I've now created basic code that tests this. i.e.

If Me.Title <> "NVQ*" Then
MsgBox NOT AN NVQ
Else
MsgBox AN NVQ
End If

It still doesn't recognise this. Any more thoughts anyone?!

Thanks
 
mous said:
If Me.Title <> "NVQ*" Then

It still doesn't recognise this. Any more thoughts anyone?!

You can't use an operator - other than Like and Not Like - with a wildcard; anything other than Like or Not Like treats the string in the expression as a literal string.
 
Fixed It.

If Not Me.Title Like "NVQ*" Then
MsgBox NOT AN NVQ
Else
MsgBox AN NVQ
End If

Thanks
 
Thanks Mile. I was under the mistaken assumption that <> and Not Like were equivalent in SQL. Following from your comment, and a bit of research, I see the error of my ways!

I always like to extend the frontiers of my ignorance. By recognising how much there is that I don't know, one day I may come to appreciate that I know nothing at all.
 

Users who are viewing this thread

Back
Top Bottom