Case Sensitive Search

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having a problem with the case of Find in Access 2

The FindFirst (or others) seems to be case non dependent regardless of the
Option Compare

My real table is an attached Paradox.dbf file from another sourc
so the option of changing the ID data is not possible

I have created a quick fully ASccess 2k database with one
table with two fields as a test.

My quick and dirty test code is commented below.

Can anyone please tell me what's wrong with it
or is it not possible to make a case sensitive rst.FindFirs

Option Compare Binar
Option Explici

_______________________________________________
Sub find(
Dim db As databas
Dim rst As Recordse
Dim str As Strin
Set db = DBEngine.Workspaces(0).Databases(0
Set rst = db.OpenRecordset("table1", dbOpenDynaset

'Table1 has 2 fields (both Text) AddressID and Addres
'AddressID 1 = alfa, Address 1 = alf
'AddressID 2 = ALFA, Address2= ALF

If "a" = "A" The
MsgBox "Equal" 'This works correctly with the Option Compare Databas
End If 'or Option Compare Binary 'rule

str = "addressID = 'ALFA'
With rs
.FindFirst st
If Not rst.NoMatch The
MsgBox rst!Address ' This always finds the first record (alfa
End I
End Wit
End Su

TIA Trevor
 
AFAIK, the Option Compare only applies to VBA, not to data engine uses.

While it will doubtlessly be inefficient, you could try

str = "StrComp([addressID], "ALFA", 0) = 0"
With rst
.FindFirst str
If Not rst.NoMatch Then
MsgBox rst!Address ' This always finds the first record (alfa)
End If
End With
 
Back
Top