Access 2010 Export Table to current location

I have a database that changes locations regulary.  I would like to have a button to export the table to the database's current location.
JAMES125Asked:
Who is Participating?
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
use this command

docmd.transferdatabase acexport, ' < to export the table to another database

docmd.transferspreadsheet acexport , ' < to export the table to excel

docmd.transfertext acexport , ' < to export the table to a text file

you will use

CurrentProject.path  ' to get the folder where your current database is running from
0
 
ramromconsultant Commented:
More info please.
What is "a database"
What is "the table"?
How would you discover the new location?
0
 
JAMES125Author Commented:
I tried the following but nothing happens

 DoCmd.TransferText acExport, "ExportSpec", "Export Query", CurrentProject.Path & "\test.txt"
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Rey Obrero (Capricorn1)Commented:
did you look at the folder where your database is ?

type this in the Immediate window from the VBA code window

?CurrentProject.Path

that should give you the path of the db you are working on..
0
 
JAMES125Author Commented:
The path is showing correctly when I debug.  When I click the button it appears to process the export but when I open the file nothing is there.  I verified that the query I'm exporting is full of records.  Any ideas?
0
 
Rey Obrero (Capricorn1)Commented:
did you check if the "ExportSpec" is correct for your "export query"?
0
 
JAMES125Author Commented:
This was the final solution:

 DoCmd.TransferText acExportFixed, "ExportSpec", "Export Query", CurrentProject.Path & "\test.txt"
0
 
JAMES125Author Commented:
Final Solution:

 DoCmd.TransferText acExportFixed, "ExportSpec", "Export Query", CurrentProject.Path & "\test.txt"
0
 
Rey Obrero (Capricorn1)Commented:
JAMES125,

The Export Specification is NOT the same as the Saved Exports steps.
0
 
Jeffrey CoachmanMIS LiasonCommented:
1.
Does this work if you export the query to text from the Navigation pane?
(Right click the query, and select "Export")\

2.
Does this work?
DoCmd.OutputTo acOutputQuery, "Export Query", acFormatTXT, CurrentProject.Path & "\test.txt"


...double check your Export Spec...
0
 
ramromconsultant Commented:
JAMES125: I'm glad you got what you wanted. I recommend in future asking "better questions" so we don't have to make stabs in the dark.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.