Solved

MS Access VBA exporting using Specification

Posted on 2013-01-02
3
1,048 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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 …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now