Pages

Wednesday, December 28, 2011

Check If Table Exists

If you want to know whether a table exists in the database or not.

Here is the code-

Sub check_if_table_exits()
Dim tbl As DAO.TableDef
Dim found As Boolean
Dim tbl_name_to_check As String
' PASS THE TABLE NAME U WANT TO CHECK
tbl_name_to_check = "sales_detail"
found = False
For Each tbl In CurrentDb.TableDefs
If tbl.Name = tbl_name_to_check Then
found = True
Exit For
End If
Next
If found = True Then
MsgBox "Table Found", vbInformation
Else
MsgBox "Table Not Found", vbInformation
End If
End Sub

Download Access Database

No comments:

Post a Comment