Solved

MS Access VBA exporting using Specification

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

867 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

15 Experts available now in Live!

Get 1:1 Help Now