Solved

MS Access VBA exporting using Specification

Posted on 2013-01-02
3
1,082 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

735 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