dollygoh,

This code you will have to modify, but this is what I use to get the table names from a database and add them to a combo box. You can scan the database until the table exist. The best way is to set up a timer to check every 5 seconds or so and to set an indicator when it exist.

In your code you loop until this indicator is set. This will definitely solve your problem without error trapping. Try this, if you need any assistance with this let me know.

VB Code:
  1. Private Sub GetTableNames()
  2. Dim TableTypes As Variant
  3. Dim i As Integer
  4.  
  5. On Error GoTo GetTableNamesError
  6.  
  7.  '   TableTypes = Array("Table", "Link", "Pass-through")
  8.    
  9.     '====================================================================
  10.     ' Collect all the table names in the database of the type we can use
  11.     '====================================================================
  12.    
  13.     Set dbTable = dbCurrent.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "TABLE"))
  14. '    Set dbTable = dbCurrent.OpenSchema(adSchemaTables)
  15.    
  16.     cboTableName.Clear
  17.    
  18.     With dbTable
  19.    
  20.        Do Until .EOF
  21.           For i = 0 To UBound(TableTypes)
  22.  '            If UCase(!table_type) = UCase(TableTypes(i)) Then
  23.                 cboTableName.AddItem !table_Name
  24.  '               Exit For
  25.  '            End If
  26.           Next i
  27.           .MoveNext
  28.        Loop
  29.      
  30.       .Close
  31.    End With
  32.    
  33.    cboTableName = GblContactTable
  34.    cboTableName.Tag = GblContactTable
  35.    Exit Sub
  36.    
  37. GetTableNamesError:
  38.  
  39.     Msg = "GetTableNamesError() - " & Err.Description & vbCrLf
  40.     frmMain.ErrorLog Msg
  41.     Exit Sub
  42.    
  43. End Sub