We help IT Professionals succeed at work.

Trying to export a table to another Access database file

SteveL13
SteveL13 asked
on
80 Views
Last Modified: 2017-04-17
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.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
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
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.