Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Mar 2007
    Location
    Wikltshire UK
    Posts
    152
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Detect Table Exists Across Network (Access 2007)

    Hi,

    Anyone know how to detect if a Table Exits in another Access MDB file across a network:

    Path: //OP1-PC/WorkFiles/Data1.mdb

    Table Name: TodaysDatadate

    Basically I'm looking to:

    If TodaysDatadate = True then
    transfer File And Append to Master File
    End if

    I want to be able to Eliminate operator handling when I harvest the days work from multiple operators, but want VBA in Access to detect if it needs to append a Table or not.??

    Graliv1

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Detect Table Exists Across Network (Access 2007)

    You could cretae the following function in a standard module:

    Public Function TableExists(DatabaseName As String, TableName As String) As Boolean
    Dim dbs As DAO.Database
    Dim strName As String
    On Error GoTo ErrHandler
    Set dbs = DBEngine.OpenDatabase(DatabaseName)
    strName = dbs.TableDefs(TableName).Name
    TableExists = True

    ExitHandler:
    On Error Resume Next
    dbs.Close
    Set dbs = Nothing
    Exit Function

    ErrHandler:
    Debug.Print Err.Description
    Resume ExitHandler
    End Function

    Use it like this:

    If TableExists("OP1-PCWorkFilesData1.mdb", "TodaysDatadate") Then
    ' code to transfer data goes here
    End If

    Note: for testing purposes, the funciton writes error messages to the debug window.

Posting Permissions

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