case-insensitive text

megatronixs

Registered User.
Local time
Today, 17:26
Joined
Aug 17, 2012
Messages
719
Hi all,

Is there a way to use "Option Compare Text" along with Option Compare Database and Option Explicit?
I use the below code:

Code:
If Me.Business = "TYPE 1" And Me.Case = "Sent Email" Then
But if "TYPE 1" is writen as "Type 1" it will give error mismatch.

Any ideas?

Greetings
 
You could just do this:

Code:
If StrConv(Me.Business, vbUpperCase) = "TYPE 1" And Me.Case = "Sent Email" Then
 
Option Compare is the statement you declare to tell the compiler what sort of comparison you wish to perform. The three values you can use are,

Option Compare Binary
Option Compare Text
Option Compare Database

Option Compare Database, is specifically for Access. If you want to make sure it does Text and not binary, replace the word with Text.
 
HI Mile-O,

It actually started to work any way. No clue what happened there, maybe...
I tried to use:
Code:
If Me.Business = "TYPE 1" Or "TYPE 2" And Me.Case = "Sent Email" Then
and that did not work out :-(
I just made line by line and it works.
I still need to solve a message that pops up aksing me If I want to make the change and I can close that point.

Greetings.
 
Code:
If Me.Business = "TYPE 1" Or "TYPE 2" And Me.Case = "Sent Email" Then

Should be:

Code:
If (Me.Business = "TYPE 1" Or Me.Business = "TYPE 2") And Me.Case = "Sent Email" Then

Note the brackets to group the OR together, otherwise your logic would be like this

Code:
Me.Business = "TYPE 1"

OR

Code:
Me.Business = "TYPE 2" AND Me.Case = "Sent Email"
 

Users who are viewing this thread

Back
Top Bottom