Is anyone aware of any methods in VB to check whether a table exists in an access database?
Thanks.
Printable View
Is anyone aware of any methods in VB to check whether a table exists in an access database?
Thanks.
Try this code:Private Sub Command1_Click()
On Error GoTo TestTable
Dim db As Database
Dim rst As Recordset
Dim tbl As String ' This is the Table you're looking for
tbl = InputBox("Put the table name")
Set db = DBEngine.OpenDatabase("C:\TestT.mdb")
Set rst = db.OpenRecordset(tbl)
MsgBox "Your Recordset " & tbl & " is exist"
Exit Sub
TestTable:
If Err.Number = 3078 Then
MsgBox "Recordset " & tbl & " doesn't exist."
Else
MsgBox " Error: " & Err.Number & " - " & Err.Description
Exit Sub
db.Close
rst.Close
End If
End Sub