+ Reply to Thread
Results 1 to 11 of 11

Export Access queries as csv files?

  1. #1
    Registered User
    Join Date
    09-08-2015
    Location
    usa
    MS-Off Ver
    2010
    Posts
    73

    Export Access queries as csv files?

    I am trying to figure out the best way for the process below, might need to post in the Access forum though.

    I have a database and need to export multiple different files and upload them on a FTP, should I export them into excel first then switch it over to an txt or can I go from Access to txt. Assuming there is a program that can automate the export straight to a txt.

    This would be a daily task possibly more than once a day.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: Excel to txt ?

    What is the format of the data in Access? What is the desired txt format? In particular, what is your Access database schema like? Is it many tables with foreign keys, etc., that have to be joined to generate the data?

    I am not seeing any reason to add an extra step of going through Excel, but I'm pretty rusty on Access.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    09-08-2015
    Location
    usa
    MS-Off Ver
    2010
    Posts
    73

    Re: Excel to txt ?

    Not sure what you mean by the format of data in Access, teaching myself as I go. The txt format needs to be three comma-delimited ASCII Text files.

    First file will have max of 4 tables. (details)
    Second file should only have one table (this table is also in first file) (header)
    Third file one table as well (will be just one field from same table in second file)

    Each file will have to be saved with today's date then an incremental number marking the number of files exported each day followed by set wording. Example below.

    First export 03-31-2021-1Header.txt 03-31-2021-1Details.txt 03-31-2021-1Approved.txt
    Second export 03-31-2021-2Header.txt 03-31-2021-2Details.txt 03-31-2021-2Approved.txt

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: Excel to txt ?

    So each table in your Access schema is completely independent set of data, and does not link to the other tables? For example, typically a database table will have something like this:

    Street Address Zip Code
    123 Main Street 12345
    99 Hollywood Blvd 90210

    Zip City State
    12345 Schenectady NY
    90210 Beverly Hills CA

    In the first table the zip code is a foreign key to the second table--it is used to look up the city and state. So if you wanted to dump a file with full addresses you would have to JOIN the two tables to get street, city, state, zip.

    Access has a feature to export a table to csv format. So I think you just need to automate with VBA to do this daily.

  5. #5
    Registered User
    Join Date
    09-08-2015
    Location
    usa
    MS-Off Ver
    2010
    Posts
    73

    Re: Excel to txt ?

    Yes I understand the basic table structure. My first export will have 2-3 foreign keys that I have to link in order to get the correct data. So I need to read up on VBA's?

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: Excel to txt ?

    You will have to use SQL statements to extract this data. I have a lot experience with SQL but not much with Access so I'm probably not your guy. But it sounds to me like, yes, this will involve VBA, unless there is something built in to export a SQL dataset to a csv file.

    I can move your question to the Access forum if you'd like.

  7. #7
    Registered User
    Join Date
    09-08-2015
    Location
    usa
    MS-Off Ver
    2010
    Posts
    73

    Re: Excel to txt ?

    Yes please, thanks.

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Export Access queries as csv files?

    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  9. #9
    Registered User
    Join Date
    09-08-2015
    Location
    usa
    MS-Off Ver
    2010
    Posts
    73

    Re: Export Access queries as csv files?

    But you can’t schedule anything in access correct?

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: Export Access queries as csv files?

    Access does support VBA and you could set up the export in VBA. I can explain how a timed event would work, but I don't know the code to extract the data. Also, Access would have to be running for the VBA to run. Another option is to schedule a Windows job to start Access and kick off the VBA, but again that is something I don't have much experience with.

  11. #11
    Registered User
    Join Date
    09-08-2015
    Location
    usa
    MS-Off Ver
    2010
    Posts
    73

    Re: Export Access queries as csv files?

    Got my export in the correct format, through trail and error, couldn't tell you what was going on.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Export Queries into multiple tabs of same workbook
    By morerockin in forum Access Tables & Databases
    Replies: 2
    Last Post: 10-09-2015, 03:41 PM
  2. [SOLVED] export from access multiple queries to same workbook into seperate sheets
    By trevor69 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2015, 04:33 AM
  3. Access Query, Based on queries, based on queries
    By Xcelguy in forum Access Tables & Databases
    Replies: 2
    Last Post: 11-13-2013, 10:15 AM
  4. Replies: 0
    Last Post: 01-21-2013, 12:47 PM
  5. Embedded Access queries in Excel - if the database moves, how to update queries?
    By Paul_mcc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-06-2012, 07:52 PM
  6. [external data] Two queries same access files...
    By El_Pablo in forum Excel General
    Replies: 0
    Last Post: 10-31-2008, 03:04 PM
  7. queries (sql) in ACCESS help
    By Sandra Aguilar in forum Excel General
    Replies: 4
    Last Post: 05-03-2005, 01:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1