Results 1 to 3 of 3

Thread: object exists

  1. #1
    Join Date
    Jun 2002
    Posts
    72

    Unanswered: object exists

    Can someone tell me what the syntax is for checking to see if a table exists or not, eg

    if isnull(object.<table_name>) then ........ does not work

    Cheers

  2. #2
    Join Date
    Jul 2002
    Location
    Australia
    Posts
    147
    I used to this code if it helps:
    Code:
    Private Function TableExists(strTableName As String) As Boolean
    
    Dim db As ADODB.Connection, rs As New ADODB.Recordset, strSQL As String
    Set db = CurrentProject.Connection
    
    strSQL = "SELECT [ID] From MSysObjects WHERE [Name] = '" & strTableName & "' AND [Type] = 1"
    rs.Open strSQL, db, adOpenForwardOnly, adLockReadOnly
    
    If rs.EOF Then
        TableExist = False
    Else
        TableExists = True
    End If
    
    rs.Close
    Set rs = Nothing
    
    End Function
    Cheers,
    Andrew
    There have been many posts made throughout the world.
    This was one of them.

  3. #3
    Join Date
    Jun 2002
    Posts
    72
    Thanks Again.

Posting Permissions

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