2009-08-06 7 views

答えて

1

はい、あなたはそれをVBAコードで行うことができます。私はあなたに電子メールを送った。

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

あなたはADOスキーマを使用することができます。

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 

も参照してください:http://support.microsoft.com/kb/186246

0

私がアクセスでメンテナンスや統合作業の多くと完全に岩アレン・ブラウンによって書かれたVBAモジュールを行います。あなたの即時ウィンドウタイプで

?Findfield("myfieldname") 

これは、特定のフィールド名が使用されている場所を見つけるためにあなたのデータベース(テーブル、クエリ、フォーム、レポート)を検索します。

文書とコードはこちらhttp://allenbrowne.com/ser-73.html

関連する問題