473,324 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Concatenate all records in 1 Field and output in Text file

Hi Everybody,

I need to concatenate all records on one field as one line.

Example: Field 1 has 50 records, record1, record2 to record50. I need to display an output in Text that read as:

record1,record2,record3,record4,record5,record6..r ecord50

No space and no line breaks.

I tried creating a report and replace vbCrLf with "" and then OutputTo text file
but I can't have it to have only only 1 line with now line breaks.

All help is appreciated.

thanks.
Jan 31 '08 #1
1 2001
ADezii
8,834 Expert 8TB
Hi Everybody,

I need to concatenate all records on one field as one line.

Example: Field 1 has 50 records, record1, record2 to record50. I need to display an output in Text that read as:

record1,record2,record3,record4,record5,record6..r ecord50

No space and no line breaks.

I tried creating a report and replace vbCrLf with "" and then OutputTo text file
but I can't have it to have only only 1 line with now line breaks.

All help is appreciated.

thanks.
Assuming your Table Name is tblTest, I created this code for a series of 50 Numbers (50 Records) in a Field named Field1:
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As DAO.Database, MyRS As Recordset, strBuild As String
  2.  
  3. Set MyDB = CurrentDb
  4. Set MyRS = MyDB.OpenRecordset("tblTest", dbOpenForwardOnly)
  5.  
  6. Do While Not MyRS.EOF
  7.   strBuild = strBuild & MyRS![Field1] & ","
  8.   MyRS.MoveNext
  9. Loop
  10.  
  11. strBuild = Left$(strBuild, Len(strBuild) - 1)    'remove trailing ,
  12.  
  13. Open "C:\BigString.txt" For Output As #1
  14. Print #1, strBuild
  15.  
  16. MyRS.Close
  17. Set MyRS = Nothing
  18.  
  19. Close #1
OUTPUT: (won't Format correctly)
Expand|Select|Wrap|Line Numbers
  1. 65328,98763,104084,105688,106755,109410,109471,113047,113062,115333,118480,118487,118509,120426,123309,126184,129286,129342,129362,129369,135984,136274,136284,136306,138280,138286,138293,138328,138344,138349,138357,138358,138365,140432,140435,140459,140468,140479,140486,143019,143027,143043,144793,144794,144798,144803,144810,144814,144835,146336
Feb 1 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Chris Kettenbach | last post by:
Good Morning, Sorry for xposting. Just need a liitle help. I have an xml file that's generated from a database. How do I select distinct values from a field in xslt and then loop through the...
5
by: gwarning! | last post by:
Goal: Have multiple text files, each of various lengths, be concatenated together into one final consolidated text file. Problem: Since the names of the files to be concatenated can change from...
8
by: Dixie | last post by:
I have the results of a query to send to a mailmerge with Word 2000. The query produces say 6 to 8 records, where only 1 of the fields is different from record to record. I can only have one...
4
by: jpr | last post by:
hello, I have a form with four fields: Fname, Lname, DOB and txtresult. Examples: JOHN, SMITH, 03/19/2006. The first three are bound to a table while the txtresult is unbound. I would...
2
by: ffimbel | last post by:
Hi, I would like to find out the fastest way to concatenate large (200 or 300MB) and numerous (500 - 700) files (Postscript files) into a single one (which can ends up being several GigaB)...
4
by: Dan | last post by:
Hi all, I am creating a search table where the keywords field is made up of several text fields and this is causing me some problems. I can concatentate the text ok but i can't seem to concatenate...
6
by: drazenj | last post by:
Hi , sorry for my english ... I work in high school as a teacher and try to make CLASS SCHEDULE (TIME schedule) for my collegues and for students . My problem is that I don't know how to...
2
by: jrheltmach | last post by:
Hi All, have a question I hope someone can help me out with. I have a file from our financial application here at work that creates invoices. In it, it pulls data from our SQL Server 2000...
10
by: Aaron Hoffman | last post by:
Hello, I'm hoping someone might be able to offer some guidance to my problem. I have one query in MS Access which consists of 2 tables joined by a SEQUENCE_ID. By joining the two tables I am...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.