Solved

MS Access VBA exporting using Specification

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

617 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