Results 1 to 11 of 11
  1. #1
    Lounger
    Join Date
    Jan 2001
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exporting to a TextFIle (2000)

    I have tree tables (1,2,3) The tables has the same record count. What I need to do is export the three tables on the same text file but the order must be
    table 1 record1
    table 2 record1
    table 3 record1
    table 1 record2
    table 2 record2
    table 3 record2
    .....next record

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Exporting to a TextFIle (2000)

    I would say this will take some VBA code. You will have to open 3 recordsets in code. Then you will need to read a record from 1 recordset, write it to the file; then read a record from rs#2, write it; then read from rs#3, then write it; then repeat.

    See Access Help for Write to see how to write to a sequential file.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Lounger
    Join Date
    Jan 2001
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Exporting to a TextFIle (2000)

    I'm trying to use VBA but I have a small problem. It replace the file when I try to copy the data. You have some idea in how to appent inf. to the text file without replace it?

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Exporting to a TextFIle (2000)

    Post the code you're using to write to the text file. You're going to have to file i/o, and it's hard to guess at what you overlooked without seeing the code.
    Charlotte

  5. #5
    2 Star Lounger
    Join Date
    Aug 2001
    Location
    Kent, England
    Posts
    108
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Exporting to a TextFIle (2000)

    Do you NEED to use VBA. Using my relatively tiny knowledge of Access could you not insert 2 fields into each table.

    FIRST field is an index of sorts (Primary key or autonumber?)
    SECOND field denotes the table it belongs to (1, 2 or 3?)

    Could you then append data from all tables to another table of the same format & then sort by the INDEX field and then the TABLE FROM field.

    To my knowledge you should then have all your records in the order you desire, ready to export as a text file.

    But like I say, I'm no expert on Access, but I hope this helps.

  6. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Exporting to a TextFIle (2000)

    While this technique might work (stress MIGHT), it has some major flaws; plus it just isn't good technique. This "index field" you mentioned is dependent on a sort sequence (which we really don't know). For the merge to work as specified (record from table1, then from #2, then from #3) with your solution would require some common numbering scheme. That is, there needs to be 3 records with the same common "index field" (one from each table). So if a new record is added, or one deleted, you have to renumber the records each time you run the merge.

    As for storing a table #, you can easily add this to a query so storing it is superfluous.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  7. #7
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Exporting to a TextFIle (2000)

    I'm not sure. After opening the output file, I'd first read thru the records until I got to an EOF. Then try writing to file.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  8. #8
    2 Star Lounger
    Join Date
    Aug 2001
    Location
    Kent, England
    Posts
    108
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Exporting to a TextFIle (2000)

    I was making the assumption (always a bad thing to do!!) that the tables in their own right were already sorted in the required order.

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Exporting to a TextFIle (2000)

    Sorts don't hold when you export a table. The records are exported in natural order.
    Charlotte

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Exporting to a TextFIle (2000)

    One of the arguments for the Put statement is record number. If you want to append a record to the end of a text file, you give it the highest record number in the text file plus 1. That means you have to know how many records are already in the text file, and you do that in the Get part of the code. If you don't post your code, all we're doing is guessing at what you might be doing wrong, and that can go on forever.
    Charlotte

  11. #11
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Exporting to a TextFIle (2000)

    >>I was making the assumption (always a bad thing to do!!) that the tables in their own right were already sorted in the required order.<<

    Very bad assumption. Access tables are NEVER sorted. You may see them displayed in a sorted order (Access will often default to ordering the output by the primary key if no other order specified), but the records in the table are not rearranged.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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