Table data to be transferred does not exist

D

dmoon72

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
 
J

John Nurick

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top