Solved

MS Access VBA exporting using Specification

Posted on 2013-01-02
3
1,062 Views
Last Modified: 2013-01-02
Hello,

I created and saved a new specification to output a table to text which can be viewed inside the Saved Exports tab but the VBA returns an error message saying the text file specification "kkk" does not exist.  Can you please help?

I only changed the name of the "file specification" as the below code has been working for years however I can manually use the Specification.

Private Sub EXPORT_Click()
DoCmd.SetWarnings False
DoCmd.Hourglass True
Dim db As Database
Dim rs As Recordset
Dim qdf As String
qdf = DLookup("GLcount", "1f2_Admin_Exp_Table_StatsTot")
Set db = CurrentDb
    DoCmd.OpenQuery "1f6a_check_req_tbl_DELETE", acViewNormal, acEdit
    DoCmd.OpenQuery "1f6c_check_req_append_MD", acViewNormal, acEdit
    DoCmd.TransferText acExport, "Export-tblCk_Requests", "tblCk_Reqs", "S:\Finance\Accounting Operations\National Accounts\Consortium Pricing\PAR\nasco_ap_ck_md.txt", False, ""
    DoCmd.OpenQuery "QdelTblCK_regsAll", acViewNormal, acEdit
    DoCmd.OpenQuery "QappTblCK_regsAllmd", acViewNormal, acEdit
    DoCmd.OpenQuery "1f6a_check_req_tbl_DELETE", acViewNormal, acEdit
    DoCmd.OpenQuery "1f6b_check_req_append_DC", acViewNormal, acEdit
    DoCmd.TransferText acExport, "Export-tblCk_Requests", "tblCk_Reqs", "S:\Finance\Accounting Operations\National Accounts\Consortium Pricing\PAR\nasco_ap_ck_dc.txt", False, ""
    DoCmd.OpenQuery "QappTblCK_regsAlldc", acViewNormal, acEdit
DoCmd.Hourglass False
        MsgBox "The MD and DC files have been copied to the S drive, please verify the totals and copy them to the R drive!!"
DoCmd.SetWarnings True
End Sub


Thanks,
Bob
0
Comment
Question by:CFMI
  • 2
3 Comments
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 38737778
< created and saved a new specification to output a table to text which can be viewed inside the Saved Exports tab but the VBA returns an error message saying the text file specification "kkk" does not exist. >
This illustrate the confusion over "Saved Exports" and "Export Specifications"

They *are not* the same thing and cannot be used interchangeably.

<I created and saved a new specification to output a table to text which can be viewed inside the Saved Exports tab>
Then you created a "Saved Export", ...*Not* and export Specification.
Only Saved Exports are exposed on the Saved Exports tab, ...not Export Specifications

You create a saved export/import by clicking the "Save Export/import steps" button at the end of an Import/Export.

You create a import/export "Specification", by clicking on the "Advanced" button while doing a manual import/export. and saving the Spec as a name.

You *can* use a Import/Export specification in code.
You *cannot* use a saved import/export in code, you must access saved import/Exports manually through the ribbon tab

(Conversely, you cannot "see" any import/export Specifications on the Ribbon/tab, these are only really visible in the MsysObjects table.
In other words, you just have to remember the name of your Specification if you want to use it in code.


"Saved Import/Exports" were created as a way for an average user to do the same import/export without knowing any code.

;-)

JeffCoachman
0
 
LVL 1

Author Closing Comment

by:CFMI
ID: 38737842
It worked; Thank you as I also learned that the two are separate functions.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38737846
In other words, if you want to use a predefined set of parameters "in VBA code", you must create an Import/Export Specification manually, then remember the name:
.......
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Auto-generated ID's in MS Access 9 46
VBA SQL statement - 2 "OR"s and 1 "And" 4 27
DCount Type Mismatch 2 21
My SQL as Backend for Access 3 14
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

776 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