다음은 고려할 수있는 대안입니다. 그것은 예쁘지 않지만 작동하는 것 같습니다.
아이디어는 사용자가 악센트 부호가없는 검색어를 입력하게하고 VBA 코드는 지정된 악센트가없는 문자를 가능한 변형 목록으로 대체합니다 (예 : o
가 너무
... LIKE '%loffel%'
는
... LIKE '%l[oö]ffel%'
사용하여 코드를 다음과 같이되고, [oö]
으로 대체됩니다 :
Option Explicit
Sub so38010103()
Dim oChars As String
' e.g., U+00F6 is "Latin Small Letter O With Diaeresis"
oChars = "[o" & ChrW(&HF6) & "]"
' (add other accented "o"s above, and other character lists below, as needed)
'test data
Const searchFor = "loffel"
Dim conn As New ADODB.Connection
conn.Open _
"DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};" & _
"DBQ=C:\Users\Public\so38010103.accdb"
Dim cmd As New ADODB.Command
cmd.ActiveConnection = conn
cmd.CommandType = adCmdText
cmd.CommandText = "SELECT COUNT(*) AS n FROM CustomerTable WHERE (CustomerName LIKE ?)"
cmd.Parameters.Append cmd.CreateParameter("?", adVarWChar, adParamInput, 255)
Dim rst As ADODB.Recordset
' test 1: literal search
cmd.Parameters(0).Value = "%" & searchFor & "%"
Set rst = cmd.Execute
Debug.Print rst(0).Value & " record(s) found" ' 0 record(s) found
rst.Close
' test 2: replace "o" with list of accented variants
cmd.Parameters(0).Value = "%" & Replace(searchFor, "o", oChars, 1, -1, vbTextCompare) & "%"
Set rst = cmd.Execute
Debug.Print rst(0).Value & " record(s) found" ' 1 record(s) found
rst.Close
conn.Close
End Sub
'O' <>'O', 그 모든 인코딩과 문자 집합에 대한 사실 . 그래서 나는 생각한다. – Andre
@Andre처럼 나는 그렇게 생각하지 않습니다. 그러한 문자를 대체 할 수 있습니까? '% l? ffel %' '로 표시됩니다. 물론 Lüffel, Léffel, Läffel도 일치 할 것이지만 아마도 0 번 경기보다 좋을 것입니다. – Gustav