|
-
Apr 30th, 2000, 06:54 AM
#1
Is anyone aware of any methods in VB to check whether a table exists in an access database?
Thanks.
-
Apr 30th, 2000, 12:25 PM
#2
Lively Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|