473,385 Members | 1,396 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,385 software developers and data experts.

Macro that exports data from a query to an OUTPUT textfile without QUOTES

Hi I would like to know if there is a macro that can export the data from a query to an output textfile that has NO QUOTES.


If I run the concatenated query Expr1: [SEQ_NUM] & [TYPE] & [DECLARANTS] & [FILENAME] & [CALENDAR_YR] & [O/R] & [DECLARATION_STATUS] & [NAME_BUSNAME_DEC]


and export it in Export Text wizard as text, with delimited, Other: | (pipeline)
and Text qualifier as none>next>finish

I can get the desired output without quotes. But this is a very long process for a user.

Can you suggest a macro that can output textfile from a query without quotes so I can just use a macro in a Command button.

I would like to export data from an existing concatenated query Expr1.



sql view of query:
SELECT [SEQ_NUM] & [TYPE] & [DECLARANTS] & [FILENAME] & [CALENDAR_YR] & [O/R] & [DECLARATION_STATUS] & [NAME_BUSNAME_DEC] AS Expr1
FROM [RT1_Declarant_ Information_1];



desired output in text file:

000000041DIRF2008R1SMITH,JULES
000000051DIRF2008O2WAYNE,BRUCE
000000061DIRF2008O2ANDREWS,RENEE
000000071DIRF2008O1ALLEN,MARK
000000081DIRF2008O1OWEN,HALLE
000000091DIRF2008O1MOONIE,IAN
000000101DIRF2008O1CASTILLO,MANUEL
000000111DIRF2006R1AMANTE,POPE
000000121DIRF2002R1SALTA,NEIL
000000131DIRF2003R1CANOR,SANDRA
000000141DIRF2004R1CANOR,FRANCIS
000000151DIRF2007R1MEJIA,MELINDA
000000161DIRF2008R1AQUINO,JANET
000000171DIRFR1CASTRO,ANDY


Thank you for your time.
Jul 17 '08 #1
1 4105
ADezii
8,834 Expert 8TB
There is probably a shorter method, but this code should produce the exact results you are looking for, just make the necessary substitutions for strQueryName and strOutputFilePath.
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As DAO.Database
  2. Dim MyRS As DAO.Recordset
  3. Dim strQueryName As String
  4. Dim strOutputFilePath As String
  5.  
  6. strQueryName = "qryEmployees"
  7. strOutputFilePath = "C:\Testi\Outputfile.txt"
  8.  
  9. Set MyDB = CurrentDb
  10. Set MyRS = MyDB.OpenRecordset(strQueryName, dbOpenSnapshot)
  11.  
  12. Open strOutputFilePath For Output As #1
  13.  
  14. Do While Not MyRS.EOF
  15.   Print #1, MyRS![Expr1]
  16.   MyRS.MoveNext
  17. Loop
  18.  
  19. Close #1
  20. MyRS.Close
  21. Set MyRS = Nothing
OUTPUT based on sample Northwind data:
Expand|Select|Wrap|Line Numbers
  1. DavolioNancySales RepresentativeSeattle
  2. FullerAndrewVice President, SalesTacoma
  3. LeverlingJanetSales RepresentativeKirkland
  4. PeacockMargaretSales RepresentativeRedmond
  5. BuchananStevenSales ManagerLondon
  6. SuyamaMichaelSales RepresentativeLondon
  7. KingRobertSales RepresentativeLondon
  8. CallahanLauraInside Sales CoordinatorSeattle
  9. DodsworthAnneSales RepresentativeLondon
Jul 20 '08 #2

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

Similar topics

1
by: Todd | last post by:
Hello, I'm am creating a CSV text import file for another application from my Access database. The other application requires a leading and following space surrounding a hyphen in the field...
0
by: JM | last post by:
How can I store following query output to multi dimensional array or something better? I will be using the output for print queue information reference later in program. ObjectQuery...
4
by: vighnesh | last post by:
Hello EveryOne In my project I have to parse a string in Quotes as without Quotes.I tried the following code but it didn't work to me. I again getting the string with Quotes, Can Anybody suggest...
8
by: GeorgeSmiley | last post by:
Does anyone know of a way, via VBA, to set the screen position of query results to a particular top, left position? I've glanced at API techniques but cannot find exactly what will do the trick....
6
by: c676228 | last post by:
Hi everyone, I wrote a store procedure that fetch one row data in the database based on the parameter value I entered. After I created the store procedure, the store procedure code looks like...
0
by: ramaraog80 | last post by:
Hi, I need a VB Script which exports data from CSV file to MySql Database Regards Ramarao G
1
by: Phil | last post by:
Is it possible to swap rows and columns in select query output so that each record's data is displayed in a column? I want to collect data each day and display it in a query with each day's date...
2
by: bhanuk | last post by:
how to get data from a textfile by clicking the button using vb6.0
7
ollyb303
by: ollyb303 | last post by:
Hi, I am having a bit of a problem with TransferText macro. I am using TransferText, Export Delimited (no field names) to export the results of a query as a .csv file. The query is based on...
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.