Thanks very much Roy and Allen (again). I modified what you suggested to do
the trick. Just for completeness and to help anyone else who has this issue,
the final code is:
Dim strSQL As String
Dim tbl As TableDef
' Used for SQL Server database which attaches a "dbo_" to the front of
table names.
strSQL = "SELECT * FROM MSysObjects WHERE Type = 4;" ' Type 4
= ODBC
If funRecordCount(strSQL) > 0 Then ' Check
if a record is found
For Each tbl In CurrentDb.TableDefs
If Len(tbl.Connect) > 0 Then
tbl.Name = Replace(tbl.Name, "dbo_", "")
End If
Next
Set tbl = Nothing
End If
funRecordCount is a generic function I use in the application
Public Function funRecordCount(strSQL As String) As Integer
Dim dbs As Database
Dim rst As Recordset
On Error GoTo Error_funRecordCount
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQL, dbOpenSnapshot, dbSeeChanges)
' Find the number of records. First test records were found.
If (rst.EOF = True) And (rst.BOF = True) Then
funRecordCount = 0
Else
rst.MoveLast
funRecordCount = rst.RecordCount
End If
Exit_funRecordCount:
Set dbs = Nothing
Set rst = Nothing
Exit Function
Error_funRecordCount:
MsgBox "Error in funRecordCount " & Err.Number & " - " & Err.Description
GoTo Exit_funRecordCount
End Function