Code VBA qui fait le matching

Bonjour,

J'ai in soucis avec ce code, quelequ'un peut m'aider?

J’ai deux tables qui contient les noms des rapports, et je veux faire le matching entre les deux en cherchant les noms qui matchent, mais dans mon code y a une erreur que je n’arrive pas à trouver :

Merci d'avance

Sub isMatche()
    Dim db As DAO.Database
    Dim myrst As DAO.Recordset
    Dim myrst1 As DAO.Recordset
    Dim myrst2 As DAO.Recordset
    Dim myrst3 As DAO.Recordset
    Dim sSQL As String
    Dim dSQL As String
    Dim mSQL As String
    Dim tSQL As String
    Dim serchName As String
    Dim nomDistinct As String
    Dim nomTypique As String

   Set db = CurrentDb

    sSQL = "select id_type, mRapport, LEN(nom) as lenght from ModelType ORDER BY lenght DESC"

    Set myrst = db.OpenRecordset(sSQL)
    'requete cherche et supprime les doublons et aditionne le nombre d'executions
    dSQL = "Select numRap, nomRapportModifié, SUM(nbExecution) from RapportModifie GROUP BY nomRapportModifié"
    'listeRaportModifieDestincte() = db.Execute(dSQL)
     Set myrst1 = db.OpenRecordset(dSQL)

    Do While Not myrst1.EOF
    'tanque il y a des enregistrement dans la liste listeRaportModifieDestincte.
        nomDistinct = myrst1.Fields(nomRapportModifié).ToLower()
        While Not myrst.EOF
        myrst.MoveNext
            nomTypique = myrst.Fields(mRapport).ToLower()
            '//LCase(nomTypique)
            If serchName = InStr(nomDistinct, nomTypique) <> 0 Then

            'Instr(4, SearchString, SearchChar, 1)
            mSQL = "UPDATE RapportModifie SET matchReportModel = nomTypique WHERE id = listeRaportModifieDestincte.numRap"
            Set myrst2 = db.OpenRecordset(mSQL)

            'Dim SearchWithinThis As String = "ABCDEFGHIJKLMNOP"
            'Dim SearchForThis As String = "DEF"
            'Dim FirstCharacter As Integer = SearchWithinThis.IndexOf(SearchForThis)

                Exit Do
            End If
        Wend
        Loop
    ' une vue qui contient le nombre occurrence de chaque rapport typique
    tSQL = "CREATE VIEW RapportCreer AS SELECT matchReportModel, SUM(nbExecution) as nbr_Occur FROM RapportModifie GROUP BY matchReportModel"
   Set myrst3 = db.OpenRecordset(tSQL)

myrst.Close
Set myrst = Nothing
myrst1.Close
Set myrst1 = Nothing
myrst2.Close
Set myrst2 = Nothing
myrst3.Close
Set myrst3 = Nothing
    db.Close
End Sub

Salut,

Peut-être que l'erreur vient de ton fichier. On peut le voir ?

Cordialement

Rechercher des sujets similaires à "code vba qui fait matching"