Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA import code...

Status
Not open for further replies.
Oct 22, 2001
215
US
I am trying to import data file into an existing table in Access using VBA. The following commands can import fine but it does not import to the existing table. If the table exists, it just create a new table with an incriment...like :Existing Table1
I just don't know why it does not import to the same table....

DoCmd.TransferDatabase TransferType:=acImport, _
DatabaseType:="Dbase IV", _
databasename:="c:\mydb, ObjectType:=acTable, _
Source:=data.dbf, _
Destination:="Existing Table"
Can any one help? Thanks in advance....
 
Hi!

As far as I know there is no way to append information when using the transferdatabase method. If you are trying to append the data then I would recommend linking to the table in the external database and setting up an Append Query to add the data to the existing table which you can then run on a regular basis. If you are trying to replace the existing table, then just delete it before running the transferdatabase method.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Hi, as far i know Jeff is rigth, but you will never know. A solution for this issue is tranfer the links to the source Table using DAO like Above. Be careful This Function was created to link Exclusive.

Function LinkExclusive(LinkedName As String, SourceDB As String, SourceTable As String) As Integer
'
' TransferDatabase links tables with the SHARED attribute. There is no setting
' to change this. LinkExclusive uses DAO to link an Access table exclusively.
'
' Arguments:
' LinkedName = Name that the linked table will be called
' SourceDB = The path to where the table actually resides
' SourceTable = The name of the actual table
'
' Returns: TRUE = OK; FALSE = error
'
Dim Db As DAO.Database, TD As DAO.TableDef
On Error GoTo LEx_Error
Set Db = CurrentDb
Set TD = Db.CreateTableDef(LinkedName)
TD.SourceTableName = SourceTable
TD.Connect = ";DATABASE=" & SourceDB & ";"
TD.Attributes = dbAttachExclusive
Db.TableDefs.Append TD
LinkExclusive = True

LEx_Exit:
Exit Function

LEx_Error:
LinkExclusive = False
Resume LEx_Exit
End Function
Best Regards

---
JoaoTL
NOSPAM_mail@jtl.co.pt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top