Results 1 to 2 of 2

Thread: Checking whether a table exists in an mdb

  1. #1
    Guest
    Is anyone aware of any methods in VB to check whether a table exists in an access database?

    Thanks.

  2. #2
    Lively Member
    Join Date
    Aug 1999
    Location
    Malaysia
    Posts
    108

    Cool

    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
  •  



Click Here to Expand Forum to Full Width