Making .FindFirst Case-Sensitive

M

martinsones

I have a search form which uses some code that looks like this :

strCrit = strField & " = """ & Me!txtCrit & """"
rst.FindFirst strCrit

On one computer this gives a case-sensitive search and on another it
is non-case-sensitive. Both are running Access 2000.

Changing 'Option Compare Database' to 'Option Compare Binary' in the
declarations section of the module doesn't seem to alter this.

Does anyone know of a way of controlling this ?
 
A

Allen Browne

It should be case insensitive.
Perhaps there is a difference in language settings.

There is not an efficient way to get JET to perform case sensitive
comparisons, but if you are stuck this kind of thing should work:
strCrit = "StrComp([" & strField & "],""" & Me!txtCrit & """, 0) = 0"
 
M

martinsones

Thanks Allen. This may well work for the example I gave but (there's
always a but!) my search form also gives the option to search 'start
of the field' or 'whole field' something like :

strCrit = strField & " Like ""*" & Me!txtCrit & "*"""

or

strCrit = strField & " Like ""*" & Me!txtCrit & """"

then

rst.FindFirst strCrit

...... so I don't think I can use strComp in these cases ?

Sorry, I should have told the whole story in the first place instead
of over-simplifying it.

Any idea why I get different results on different PC's ? I can't find
an application-level setting that would cause this.

Thanks again.

Martin





Allen said:
It should be case insensitive.
Perhaps there is a difference in language settings.

There is not an efficient way to get JET to perform case sensitive
comparisons, but if you are stuck this kind of thing should work:
strCrit = "StrComp([" & strField & "],""" & Me!txtCrit & """, 0) = 0"

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

I have a search form which uses some code that looks like this :

strCrit = strField & " = """ & Me!txtCrit & """"
rst.FindFirst strCrit

On one computer this gives a case-sensitive search and on another it
is non-case-sensitive. Both are running Access 2000.

Changing 'Option Compare Database' to 'Option Compare Binary' in the
declarations section of the module doesn't seem to alter this.

Does anyone know of a way of controlling this ?
 
A

Allen Browne

What's the language setting in the Windows Control Panel (under Regional
Settings)?

How about in the database, under:
Tools | Options | General | New Database Sort Order

Do the machines have the same version of msjet40.dll (typically in
Windows\System32)?

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Thanks Allen. This may well work for the example I gave but (there's
always a but!) my search form also gives the option to search 'start
of the field' or 'whole field' something like :

strCrit = strField & " Like ""*" & Me!txtCrit & "*"""

or

strCrit = strField & " Like ""*" & Me!txtCrit & """"

then

rst.FindFirst strCrit

..... so I don't think I can use strComp in these cases ?

Sorry, I should have told the whole story in the first place instead
of over-simplifying it.

Any idea why I get different results on different PC's ? I can't find
an application-level setting that would cause this.

Thanks again.

Martin





Allen said:
It should be case insensitive.
Perhaps there is a difference in language settings.

There is not an efficient way to get JET to perform case sensitive
comparisons, but if you are stuck this kind of thing should work:
strCrit = "StrComp([" & strField & "],""" & Me!txtCrit & """, 0) = 0"

I have a search form which uses some code that looks like this :

strCrit = strField & " = """ & Me!txtCrit & """"
rst.FindFirst strCrit

On one computer this gives a case-sensitive search and on another it
is non-case-sensitive. Both are running Access 2000.

Changing 'Option Compare Database' to 'Option Compare Binary' in the
declarations section of the module doesn't seem to alter this.

Does anyone know of a way of controlling this ?
 
M

martinsones

Thanks for your advice Allen, I'll check those settings out.

Martin




What's the language setting in the Windows Control Panel (under Regional
Settings)?

How about in the database, under:
Tools | Options | General | New Database Sort Order

Do the machines have the same version of msjet40.dll (typically in
Windows\System32)?

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


Thanks Allen. This may well work for the example I gave but (there's
always a but!) my search form also gives the option to search 'start
of the field' or 'whole field' something like :
strCrit = strField & " Like ""*" & Me!txtCrit & "*"""

strCrit = strField & " Like ""*" & Me!txtCrit & """"

rst.FindFirst strCrit
..... so I don't think I can use strComp in these cases ?
Sorry, I should have told the whole story in the first place instead
of over-simplifying it.
Any idea why I get different results on different PC's ? I can't find
an application-level setting that would cause this.
Thanks again.

Allen Browne wrote:
It should be case insensitive.
Perhaps there is a difference in language settings.
There is not an efficient way to get JET to perform case sensitive
comparisons, but if you are stuck this kind of thing should work:
strCrit = "StrComp([" & strField & "],""" & Me!txtCrit & """, 0) = 0"
I have a search form which uses some code that looks like this :
strCrit = strField & " = """ & Me!txtCrit & """"
rst.FindFirst strCrit
On one computer this gives a case-sensitive search and on another it
is non-case-sensitive. Both are running Access 2000.
Changing 'Option Compare Database' to 'Option Compare Binary' in the
declarations section of the module doesn't seem to alter this.
Does anyone know of a way of controlling this ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top