Results 1 to 2 of 2

Thread: Checking Table Exist in Access Database or Not

  1. #1
    Member littleiitin's Avatar
    Join Date
    Aug 2011
    Posts
    90
    Rep Power
    13

    Checking Table Exist in Access Database or Not

    Code:
    Option Explicit
    
    Sub TableExits(strDBPath As String, strTable As String)
        
        Dim adoConn     As Object
        Dim rstRec      As Object
            
        Set adoConn = CreateObject("ADODB.Connection")
        Set rstRec = CreateObject("ADODB.Recordset")
        
        adoConn.Open "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & strDBPath & ";"
        On Error GoTo xxx:
        rstRec.Open "Select * from " & strTable, adoConn, 3, 3
    xxx:
        If Err.Number = -2147217865 Then
            MsgBox "Table does not Exist.", vbInformation, "Table Exists or Not"
        Else
            MsgBox "Table Exists.", vbInformation, "Table Exists or Not"
        End If
        
    End Sub
    How to Use:

    Code:
    Sub test()
    
        Dim strDBPath   As String
        Dim strTable    As String
        '===========DB Path======
        strDBPath = "K:\xys\XYZDB.mdb"
        '=======================
        '=====Table Name=========
        strTable = "abc"
        '=======================
        Call TableExits(strDBPath, strTable)
        
    End Sub

  2. #2

Similar Threads

  1. Compact and Repair MS Access Database
    By LalitPandey87 in forum MS-Access Tips And Tricks
    Replies: 8
    Last Post: 04-17-2017, 03:41 PM
  2. Export data from Excel to Access Table (ADO) using VBA
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 4
    Last Post: 02-24-2015, 07:53 PM
  3. Delete Double Entry From Access DBF Table
    By MASIF in forum Access Help
    Replies: 1
    Last Post: 03-07-2013, 11:40 AM
  4. Do Not AutoFilter If Data Does Not Exist
    By xander1981 in forum Excel Help
    Replies: 14
    Last Post: 10-15-2012, 06:46 PM
  5. Delete Duplicate Records from Access Table
    By littleiitin in forum Access Help
    Replies: 7
    Last Post: 08-23-2012, 10:30 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •