Re: MD5 Hash with single quote = grief in dao.findfirst

From: Stephen Rasey (raseysm_at_wiserways.com)
Date: 08/17/04


Date: Mon, 16 Aug 2004 23:53:00 -0500

No
Option Compare Binary
was not the solution. Binary is the default anyway. It tried the Sub
TestH70Ado using an Option Compare Text and it did not help.

I could not use Option Compare Database. Odd, huh? 'Compare Database' is
only available from Access according to the help.

I am doing all this from Excel VBA. I have the Access 11.0 library
referenced, but it still will not take Option Compare Database. I doubt my
problem is caused by running DAO.recordset from excel. If it is, then it
certainly is a bug.

I have the ADO working. I have always prefered DAO (simpler setups), but I
guess I'll have to prefer ADO of DAO if I can't trust DAO.

Stephen Rasey
WiserWays
Houston
http://excelsig.org

Sub TestH70Ado()
    H02_Define_H_Recordsets
    Dim strH As String
    Dim ID As Long

    ID = H70Check("$¥¨3¶¯ô¼.Ë©£F³Ñ") 'Answer is -1915054114 works
    ID = H70CheckADO("$¥¨3¶¯ô¼.Ë©£F³Ñ") 'Answer is -1915054114 works
    ID = H70Check("-s3ë=­'[+@û;ÒëN") 'Answer is supposed to be
1106461086, returns 0
    ID = H70CheckADO("-s3ë=­'[+@û;ÒëN") 'Answer is 1106461086 works.
End Sub

Function H70Check(strHash As String) As Long
    'return the IDHashProspSched if the strHash is found in
H70HashProspSched
    'return 0 if not found. Protect against 0 being a legitimate ID.
    Dim sql As String
    sql = "HASH = '" & wwQuoteFix(strHash) & "'" 'Rasey 040804 v24j
      With rsH70ProspSched
        .Requery
        .MoveFirst 'rasey 040813 test
        .FindFirst sql
        If .NoMatch Then
            H70Check = 0
        Else
            H70Check = !IDHashProspSched
        End If
    End With
End Function

Function H70CheckADO(strHash As String) As Long
    'return the IDHashProspSched if the strHash is found in
H70HashProspSched
    'return 0 if not found. Protect against 0 being a legitimate ID.
    Dim sql As String
    sql = "HASH = '" & wwQuoteFix(strHash) & "'" 'Rasey 040804 v24j
    With adorsH70
        .Requery
        .MoveFirst 'With ADO, to do a find first, you must do a
MoveFirst, then Find.
        .Find sql
        If .EOF Then
            H70CheckADO = 0
        Else
            H70CheckADO = !IDHashProspSched
        End If
    End With

End Function

Function wwQuoteFix(str1 As String) As String
    wwQuoteFix = Replace(str1, "'", "''")

End Function

"david epsom dot com dot au" <david@epsomdotcomdotau> wrote in message
news:evZT1U0gEHA.1184@TK2MSFTNGP12.phx.gbl...
> FWIW, I don't have any problem with "single quotes' in
> DAO.findfirst, in Access 2000 or A97.
>
> Two thoughts:
> 1) You haven't set Option Compare Binary at the top of the code module?
>
> 2) If you check using AscW() instead of Asc() do you see anything
different?
>
> (david)
>



Relevant Pages

  • Re: SQL - Capture Specific Text and Copy to New Column/row
    ... I have been able to create a script which captures only those rows/columns that have the string ... Please advise of how I may capture only the date/time data. ... It treats wildcard characters as characters in the string. ... The case sensitivity is set by the Option Compare setting of the module. ...
    (microsoft.public.access.modulesdaovba)
  • Re: User Logon Name
    ... The Declare statement has to go at the top of the module. ... Option Compare Database ... "GetUserNameA" (ByVal lpBuffer As String, ... Sub TestSub ...
    (microsoft.public.access.forms)
  • Re: SQL - Capture Specific Text and Copy to New Column/row
    ... If you knew the exact length of the string you could add that into the mid. ... The case sensitivity is set by the Option Compare setting of the module. ... Option Compare Database can only be used within Microsoft Access. ... An example of the text I wish to capture and which is contained in the current table is: ...
    (microsoft.public.access.modulesdaovba)
  • Re: SQL - Capture Specific Text and Copy to New Column/row
    ... The script is: ... Please advise of how I may capture only the date/time data. ... wildcard characters as characters in the string. ... by the Option Compare setting of the module. ...
    (microsoft.public.access.modulesdaovba)
  • Reverse engineering an event
    ... Option Compare Database ... Sub BuildSQLString(strSQL As String) ... Private Sub Cancel_Click ...
    (microsoft.public.access.modulesdaovba)