Table data to be transferred does not exist

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If you are writing code and want to transfer data from a table in another db - how can you find out if the table exists in that db so that you will not request the transfer if the table does not exist
 
One approach is try the import anyway and to trap the error if the
table's not there: e.g. (for importing data from an mdb file) something
like this air code:

Dim strDBName As String
Dim strSourceTbl As String
Dim strDestTbl As String

strDBName = "D:\Folder\Filename.mdb"
strSourceTbl = "ExternalTable"
strDestTbl = "MyTable"

On Error Resume Next
DoCmd.Transferdatabase acImport, "Microsoft Access", _
strDBName, acTable, strSourceTbl, "tblTemp"
Select Case Err.Number
Case 0
MsgBox "Data imported"
Case 3011
Err.Clear
MsgBox "Could not find table"
Case Else
'Unexpected error
Err.Raise Err.Number, Err.Description & " importing " _
& strSourceTbl & " from " & strDBName & "."
End Select
On Error Goto 0






If you are writing code and want to transfer data from a table
in another db - how can you find out if the table exists in that db so
that you will not request the transfer if the table does not exist
 
Back
Top