Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Trying to export a table to another Access database file

I'm trying to export a table to an external Access database file via VBA code.  The code I'm trying is:

DoCmd.TransferDatabase acExport, "Microsoft Access", LFilename, acTable, "qryHeaderRecordsToArchive", "tblDataHeader- & Me.txtFileNameAndLocation, False"

But it isn't working.  Note LFilename is establish with:

LFilename = DLookup("[ArchiveFileLoc]", "tblSetup") & "\" & Me.txtFileNameAndLocation & ".accdb"

So I'm hoping to get the exported file table to be named tblDataHeader PLUS Me.txtFileName

In other words tblDataHeader-something  (something being the  Me.txtFileNameAndLocation  part of it.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SteveL13

ASKER

I got it with:

DoCmd.TransferDatabase acExport, "Microsoft Access", LFilename, acQuery, "qryHeaderRecordsToArchive", "tblDataHeader-" & Me.txtFileName, False


But you were correct. I needed to change acTable to acQuery