2009-08-06 3 views

Répondre

1

Oui, vous pouvez le faire Code VBA. Je t'ai envoyé un email.

Public Function FindField(fieldname As String) 


    Dim db As Database 
    Dim td As TableDef 
    Dim fd As Field 

    Set db = DBEngine(0)(0) 
    db.TableDefs.Refresh 

    For Each td In db.TableDefs 
     For Each fd In td.fields 
      If fieldname = fd.Name Then 
       Debug.Print td.Name 
      End If 
     Next 
    Next 
    db.Close 

End Function 
0

Vous pouvez utiliser ADO schemas:

Function ListTablesContainingField(SelectFieldName) As String 
    ''Tables returned will include linked tables 
    Dim cn As New ADODB.Connection 
    Dim rs As ADODB.Recordset 
    Dim strTempList As String 

     On Error GoTo Error_Trap 

     Set cn = CurrentProject.Connection 

     ''Get names of all tables that have a column called <SelectFieldName> 
     Set rs = cn.OpenSchema(adSchemaColumns, _ 
     Array(Empty, Empty, Empty, SelectFieldName)) 

     ''List the tables that have been selected 
     While Not rs.EOF 
      ''Exclude MS system tables 
      If Left(rs!Table_Name, 4) <> "MSys" Then 
       strTempList = strTempList & "," & rs!Table_Name 
      End If 
      rs.MoveNext 
     Wend 

     ListTablesContainingField = Mid(strTempList, 2) 

    Exit_Here: 

     rs.Close 
     Set cn = Nothing 
     Exit Function 

    Error_Trap: 

     MsgBox Err.Description 
     Resume Exit_Here 
    End Function 

Voir aussi: http://support.microsoft.com/kb/186246

0

Je fais beaucoup de travaux d'entretien et de l'intégration dans l'accès et un module de vba écrit par Allen Browne totalement roches.

Dans le type de fenêtre immédiate

?Findfield("myfieldname") 

Il recherche dans votre base de données (tables, requêtes, formulaires, rapports) pour trouver où l'on utilise un nom de domaine particulier.

Documentation et le code est ici http://allenbrowne.com/ser-73.html

Questions connexes