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:
Private Sub GetTableNames()
Dim TableTypes As Variant
Dim i As Integer
On Error GoTo GetTableNamesError
' TableTypes = Array("Table", "Link", "Pass-through")
'====================================================================
' Collect all the table names in the database of the type we can use
'====================================================================
Set dbTable = dbCurrent.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "TABLE"))
' Set dbTable = dbCurrent.OpenSchema(adSchemaTables)
cboTableName.Clear
With dbTable
Do Until .EOF
For i = 0 To UBound(TableTypes)
' If UCase(!table_type) = UCase(TableTypes(i)) Then
cboTableName.AddItem !table_Name
' Exit For
' End If
Next i
.MoveNext
Loop
.Close
End With
cboTableName = GblContactTable
cboTableName.Tag = GblContactTable
Exit Sub
GetTableNamesError:
Msg = "GetTableNamesError() - " & Err.Description & vbCrLf
frmMain.ErrorLog Msg
Exit Sub
End Sub