| Boolean |
結果をTrue/Falseで返します。
True- テーブルが存在する
False-テーブルが存在しない |
TableExists_FS()
Function TableExists_FS(strTable As String) As Boolean
' For Access 97/2000
Dim tdf As DAO.TableDef
TableExists_FS = False
For Each tdf In CurrentDb.TableDefs
If strTable = tdf.Name Then
TableExists_FS = True
Exit For
End If
Next
End Function |
使用例
? TableExists_FS("MyTable")
True
|
Tip:
Access 2000を使用する場合、CurrentDataオブジェクトのテーブルコレクションを使用する方法もあります。
Function TableExists2_FS(strTable As String) As Boolean
' For Access 2000
Dim obj As AccessObject
TableExists2_FS = False
For Each obj In CurrentData.AllTables
If strTable = obj.Name Then
TableExists2_FS = True
Exit For
End If
Next
End Function |