Solved

Access 2010 Export Table to current location

Posted on 2012-04-02
11
316 Views
Last Modified: 2012-04-02
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.
0
Comment
Question by:JAMES125
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 17

Expert Comment

by:ramrom
ID: 37796444
More info please.
What is "a database"
What is "the table"?
How would you discover the new location?
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 37796458
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
 

Author Comment

by:JAMES125
ID: 37796598
I tried the following but nothing happens

 DoCmd.TransferText acExport, "ExportSpec", "Export Query", CurrentProject.Path & "\test.txt"
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37796641
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
 

Author Comment

by:JAMES125
ID: 37796709
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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37796728
did you check if the "ExportSpec" is correct for your "export query"?
0
 

Author Comment

by:JAMES125
ID: 37796729
This was the final solution:

 DoCmd.TransferText acExportFixed, "ExportSpec", "Export Query", CurrentProject.Path & "\test.txt"
0
 

Author Closing Comment

by:JAMES125
ID: 37796735
Final Solution:

 DoCmd.TransferText acExportFixed, "ExportSpec", "Export Query", CurrentProject.Path & "\test.txt"
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37796739
JAMES125,

The Export Specification is NOT the same as the Saved Exports steps.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37796801
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
 
LVL 17

Expert Comment

by:ramrom
ID: 37796834
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question