Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make InStr case sensitve in MS Access

How do I make InStr case sensitive in MS Access?

I'd like the following to display 0

 msgbox InStr("In Here", "here")

Instead I get 4.

I've tried adding vbBinaryCompare

 msgbox InStr("In Here", "here", vbBinaryCompare)

but it complains about a type mismatch.

like image 812
BIBD Avatar asked Jul 19 '12 17:07

BIBD


People also ask

Is InStr function case-sensitive?

INSTR is case-sensitive. Use one of the case-conversion functions to locate both uppercase and lowercase instances of a letter or character string.


2 Answers

Use InStrB instead of InStr. Then it will do a byte by byte comparison instead of case insensitive.

 msgbox InStrB("In Here", "here")

Displays 0.

like image 149
BIBD Avatar answered Sep 22 '22 19:09

BIBD


The help topic doesn't make this point clear, but when you use the optional compare argument, you need to also supply the optional start argument in order to avoid that type mismatch complaint.

So this displays 0 in the MsgBox:

MsgBox InStr(1,"In Here", "here", vbBinaryCompare)
like image 45
HansUp Avatar answered Sep 26 '22 19:09

HansUp