473,809 Members | 2,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

11 New Member
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_STA TUS] & [NAME_BUSNAME_DE C]


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

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_STA TUS] & [NAME_BUSNAME_DE C] AS Expr1
FROM [RT1_Declarant_ Information_1];



desired output in text file:

000000041DIRF20 08R1SMITH,JULES
000000051DIRF20 08O2WAYNE,BRUCE
000000061DIRF20 08O2ANDREWS,REN EE
000000071DIRF20 08O1ALLEN,MARK
000000081DIRF20 08O1OWEN,HALLE
000000091DIRF20 08O1MOONIE,IAN
000000101DIRF20 08O1CASTILLO,MA NUEL
000000111DIRF20 06R1AMANTE,POPE
000000121DIRF20 02R1SALTA,NEIL
000000131DIRF20 03R1CANOR,SANDR A
000000141DIRF20 04R1CANOR,FRANC IS
000000151DIRF20 07R1MEJIA,MELIN DA
000000161DIRF20 08R1AQUINO,JANE T
000000171DIRFR1 CASTRO,ANDY


Thank you for your time.
Jul 17 '08 #1
1 4150
ADezii
8,834 Recognized Expert Expert
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 strOutputFilePa th.
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
2312
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 name in order to import correctly. Without the spaces, the import application crashes. I have no control over the other application so I can't change this. Problem is, when I put the space in the output field name in my query (like this (but...
0
1494
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 obj_printerq = new ObjectQuery("SELECT * FROM Win32_PrintJob"); TIA!
4
2496
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 me where I went wrong? Thanks in advance. code:
8
4919
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. I have a database with large amounts of historical data for which many queries have been built. If I used Access reports for output, I'd have to build many reports that I don't want to do. For this and other reasons, my approach to inquiries...
6
2737
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 this: ALTER proc getProductCommScale @product As varchar(30), @TISCommRate As Decimal(5,2) OUTPUT, @BrokerCommRate As Decimal(5,2) OUTPUT, @Fee As Decimal(5,2) OUTPUT As if RTRIM(@product)='Imed' Select @TISCommRate=TISComm,...
0
1222
by: ramaraog80 | last post by:
Hi, I need a VB Script which exports data from CSV file to MySql Database Regards Ramarao G
1
5977
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 along the top row and the data items below it. This would give a better appreciation of changes over time. I apologise if I'm missing something obvious. Phil
2
1277
by: bhanuk | last post by:
how to get data from a textfile by clicking the button using vb6.0
7
6030
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 a linked table and uses a CDate() expression to convert the timestamp field (Nom_Date) from the table to a date type and the criteria: Between (Now()-183) And Now() to narrow results to the last 6 months. The query works just fine on its own and...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9602
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10639
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10383
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7661
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.