Solved Error expected table (1 Viewer)

Superpat

Member
Local time
Today, 14:22
Joined
Aug 15, 2020
Messages
96
Hello Ihave this error, expected table :

:
2023-02-06_131943.png


my code :
Code:
Function fnDmwListAllModulesDeroulantes(lComptageModules As String) As String
        ' Liste les tables dans le fichier "t_ListeDeroulante dans t_OperationSauvegarde_SuperPatrickCourant_28/02/2002
        'On Error GoTo errHandler
        Dim obj As AccessObject, db As Object
        Dim bolExiste As Boolean
        Dim Table_Name As String
        Dim dbs     As DAO.Database
        Dim oRst    As DAO.Recordset
        Dim oDb     As DAO.Database
        Set oDb = CurrentDb
        Table_Name = "t_ListeDeroulanteModules"
        Set oRst = oDb.OpenRecordset(Table_Name, dbOpenDynaset)
        Set db = Application.CurrentProject
        For Each obj In db.AllModules
                With oRst
                        bolExiste = RechercheIntitule1(obj.Name, strSearch)
                        If bolExiste = True Then
                                Debug.Print "Existe : " & obj.Name
                        Else
                                .AddNew
                                ![Liste_Modules] = obj.Name
                                .Update
                        End If
                End With
        Next obj
        oRst.Close
        oDb.Close
        Set oRst = Nothing
        Set oDb = Nothing
        Dim strSQLComptageOperation As Long
        lComptageModules = DCount("Liste_Modules", Table_Name)
        'Debug.Print lComptageModules
        fnDmwListAllModulesDeroulantes = lComptageModules
procDone:
        Exit Function
errHandler:
        MsgBox Err.Number & " " & Err.Description
        Resume procDone
End Function
Code:
Function RechercheIntitule1(strModuleName As String, strSearch As String) As Boolean
        'Procédure qui vérifie si le titre existe.
        Debug.Print strModuleName
        Debug.Print strSearch
10      On Error GoTo errSub
        ' Open module.
        'DoCmd.OpenModule strModuleName
11       Set mdl = Modules(strModuleName)
12      strNomProcedure = "RechercheIntitule1"
        ' Return reference to Module object.
14      If mdl.Find(strSearch, 1, 1, -1, -1, False, False, False) Then
                ' On trouve l'intitulé
16              RechercheIntitule1 = True
18      Else
20              RechercheIntitule1 = False
22      End If
Exitsub:
24      On Error GoTo 0
26      Exit Function
errSub:
        Select Case fGestError1(strNomProcedure, Err, Erl, Err.Description)
                Case vbAbort
28                      End
                Case vbRetry
30                      Resume
                Case vbIgnore
32                      Resume Next
        End Select
End Function
Any help,thanks
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:22
Joined
May 7, 2009
Messages
19,245
did you try to debug.print which module are you in when it errors out? (maybe your are on same module you are executing the code?).
 

Superpat

Member
Local time
Today, 14:22
Joined
Aug 15, 2020
Messages
96
Thanks @arnelgp, I am sorry I try it in a form !
But i have a problem with the line 19 :
"frm.Find"
I dont know to write the name of the form.

Code:
Function RechercheIntituleFormulaire(strFormulaireName As String, strSearch As String) As Boolean
        'Procédure qui vérifie si le titre existe.
        Debug.Print strFormulaireName
        Debug.Print strSearch
10      On Error GoTo errSub

        Dim frm     As Access.AccessObject

        For Each frm In Application.CurrentProject.AllForms
                Debug.Print frm.Name
                If strFormulaireName = frm.Name Then
                        Debug.Print "FrmExist = True"
                        If frm.Find(strSearch, 1, 1, -1, -1, False, False, False) Then
                                '                ' On trouve l'intitulé
                                RechercheIntituleFormulaire = True
                        Else
                                RechercheIntituleFormulaire = False
                        End If

                        Exit For                                     'We know it exist so let leave, no point continuing
                End If
        Next frm

Exitsub:
24      On Error GoTo 0
26      Exit Function
errSub:
        Select Case fGestError1(strNomProcedure, Err, Erl, Err.Description)
                Case vbAbort
28                      End
                Case vbRetry
30                      Resume
                Case vbIgnore
32                      Resume Next
        End Select
End Function
 
Last edited:

Superpat

Member
Local time
Today, 14:22
Joined
Aug 15, 2020
Messages
96
I found a procedure :
Code:
Sub findWordInModules(ByVal sSearchTerm As String, strNomModule As String)
        'object.Find(target, startline, startcol, endline, endcol [, wholeword] [, matchcase] [, patternsearch])
        'https://msdn.microsoft.com/en-us/library/aa443952(v=vs.60).aspx

        ' VBComponent requires reference to Microsoft Visual Basic for Applications Extensibility
        '             or keep it as is and use Late Binding instead
        Dim oComponent As Object                                     'VBComponent

        For Each oComponent In Application.VBE.ActiveVBProject.VBComponents
                'Debug.Print oComponent.CodeModule
                If oComponent.CodeModule = strNomModule Then
                        If oComponent.CodeModule.Find(sSearchTerm, 1, 1, -1, -1, False, False, False) = True Then
                                Debug.Print "Module: " & oComponent.Name        'Name of the current module in which the term was found (at least once)
                                'Need to execute a recursive listing of where it is found in the module since it could be found more than once
                                'Call listLinesinModuleWhereFound(oComponent, sSearchTerm)
                        End If
                End If
        Next oComponent
End Sub
 

Users who are viewing this thread

Top Bottom