• Check if table available (2000)

    Author
    Topic
    #404038

    I have a linked table in my database, pointing to a table in a database on another machine.
    Is there a method of checking if the table is available (i.e. that the other machine is switched on) so that I can display a warning message if it can’t be contacted.
    John

    Viewing 1 reply thread
    Author
    Replies
    • #818982

      You can do something like this:

      Function IsTableAvailable(TableName As String) As Boolean
      Dim cnn As ADODB.Connection
      Dim rst As New ADODB.Recordset

      On Error Resume Next

      Set cnn = CurrentProject.Connection
      rst.Open TableName, cnn
      IsTableAvailable = (Err = 0)

      rst.Close
      Set rst = Nothing
      Set cnn = Nothing
      End Function

      This function tries to open a recordset on the table and returns True if it succeeds, False if it fails.

      • #819000

        Many thanks – works excellently (as usual)
        John

      • #819001

        Many thanks – works excellently (as usual)
        John

    • #818983

      You can do something like this:

      Function IsTableAvailable(TableName As String) As Boolean
      Dim cnn As ADODB.Connection
      Dim rst As New ADODB.Recordset

      On Error Resume Next

      Set cnn = CurrentProject.Connection
      rst.Open TableName, cnn
      IsTableAvailable = (Err = 0)

      rst.Close
      Set rst = Nothing
      Set cnn = Nothing
      End Function

      This function tries to open a recordset on the table and returns True if it succeeds, False if it fails.

    Viewing 1 reply thread
    Reply To: Check if table available (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: