473,804 Members | 2,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TransferText Export Problem

Hi All

I am using the docmd.transfert ext to export my query as a .csv file.
I am using an export spec which is seperated by a pipe.

The problem I have is that I added an extra column onto the end of my
query and updated the spec.
The new column is an integer but when I export it, it always exports
as a text field i.e "100". With quotes around it.

I have tried manipulating the queries using either cDbl or NZ
functions but no luck.

I can't see anywhere in an export spec where I can change the setting
to ensure it gets exported as a number but if anyone has any ideas
please let me know.

Thanks
Andrew

Sep 4 '07 #1
2 3505
Hi Andrew,

Here is the easiest, most reliable way to export data to a csv file (or
text file) from Access -- use VBA.

Sub ExportDataToCSV ()
Dim DB As DAO.Database, RS As DAO.Recordset, fld As DAO.Field, str1 As
String
Set DB = CurrentDb
Set RS = DB.OpenRecordse t("tbl1")
Open "c:\1A\ExportTe st1.csv" For Output As #1
Do While Not RS.EOF
str1 = ""
For Each fld In RS.Fields
str1 = str1 & fld & ","
Next
str1 = Mid(str1, 1, Len(str1) - 1) '--remove last ","
Print #1, str1
RS.MoveNext
Loop
Close #1
RS.Close
End Sub
Note: the Print command in the loop (Print #1, str1) prints/writes the
data to the csv file without quotations. There is also a Write command
(Write #1, str1) which would include double quotations around the
string. In my example I am not using quotes (using Print) so I combine
all the table fields into one string. If I wanted to surround each
table field with double quotes I would use the Write Command and do each
table field individually instead of combining the fields all into one
string. This is way more reliable than using Specs and much easier to
manipulate, maintain,...

You can find more information in the Access Help Files. Just copy this
code into a standard code module. If you have any questions on anything
-- just place the mouse cursor over the object in question (say the Open
command in Open "c:\1A\ExportTe st1.csv"...) and press the F1 key. That
will bring up Access help on that topic.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Sep 4 '07 #2
On 4 Sep, 23:22, Rich P <rpng...@aol.co mwrote:
Hi Andrew,

Here is the easiest, most reliable way to export data to a csv file (or
text file) from Access -- use VBA.

Sub ExportDataToCSV ()
Dim DB As DAO.Database, RS As DAO.Recordset, fld As DAO.Field, str1 As
String
Set DB = CurrentDb
Set RS = DB.OpenRecordse t("tbl1")
Open "c:\1A\ExportTe st1.csv" For Output As #1
Do While Not RS.EOF
str1 = ""
For Each fld In RS.Fields
str1 = str1 & fld & ","
Next
str1 = Mid(str1, 1, Len(str1) - 1) '--remove last ","
Print #1, str1
RS.MoveNext
Loop
Close #1
RS.Close
End Sub

Note: the Print command in the loop (Print #1, str1) prints/writes the
data to the csv file without quotations. There is also a Write command
(Write #1, str1) which would include double quotations around the
string. In my example I am not using quotes (using Print) so I combine
all the table fields into one string. If I wanted to surround each
table field with double quotes I would use the Write Command and do each
table field individually instead of combining the fields all into one
string. This is way more reliable than using Specs and much easier to
manipulate, maintain,...

You can find more information in the Access Help Files. Just copy this
code into a standard code module. If you have any questions on anything
-- just place the mouse cursor over the object in question (say the Open
command in Open "c:\1A\ExportTe st1.csv"...) and press the F1 key. That
will bring up Access help on that topic.

Rich

*** Sent via Developersdexht tp://www.developersd ex.com***
Thanks for the tip. Will give it a go!

I still don't understand why the field is exporting as text, but if
need be, when the file gets re-imported into access I can use a query
to change it to an integer.

Cheers

Sep 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3973
by: Sue | last post by:
Using WindowsXP and AccessXP in 2000 Mode When I run the following code, I get error 3027 "Cannot Update. Database or object is read only." StrFolder = "C:\Comic Box\WebStore Interface Database\UpLoadChangeFiles\" StrFile = "NewStoreItem" & Format(Now(), "yymmddhhnn") & ".txt" DoCmd.TransferText acExportDelim, "NewStoreItem Export Specification", "QryPFrmAddNewItemToWebstore", StrFolder & StrFile, False
2
4703
by: BigData | last post by:
I am attempting to create a delimited text file by using DoCmd.Transfertext as shown here. DoCmd.TransferText acExportDelim, "ExportSpec", "QryFinalExport", "Fileout.txt" This works fine as long as I load the .mdb or .mde directly and run. However, for various reasons, I need to reference this .mdb/.mde from my main .mde and then run the transfertext in the referenced .mde.
1
24435
by: Trevor Best | last post by:
Just been having this problem when Exporting a query. DoCmd.TransferText acExportDelim, "GenMESR Export Specification", "qryGenMESRExport", Environ$("TEMP") & "\MESR.CSV", False I get the error 3011 cannot find object 'MESR.CSV' Tried using OutputTo, which netted "database or object is read-only". Googled this group to find KB article KB225987 for A2K, which refers
3
9426
by: Oliver Gabriel | last post by:
Hi, i want to export a table for later import, using vba. That´s my code: export: filename = "C:\HVOtabelle.txt"
6
6897
by: Tim Marshall | last post by:
IN trying to export a Jet query (an actual saved Jet querydef which is written against a pass through query - not that that should be a problem) to text via either the File->Export... menu item or using Transfertext, I get an error to the effect that permission is denied. The VBA line shown below - I tried using the specification DoCmd.TransferText acExportDelim, "QryOracleView Export Specification", "qryOracleView", strSaveFile, -1
0
2033
by: Sean Howard | last post by:
I have a strange problem linking tab delimited text files in Access 2000 (I am running Windows XP), please try this and let me know if I am going mad. Step 1. Create the tab-delimited text file below in WordPad and call the file "HeaderYES.txt" (the space between the two fields is actually a tab):- "Column1" "Column2" 1 "Line1"
5
2137
by: Dave | last post by:
Hello, I have a possible problem exporting a text field that happens to contain dates (but is not a date field) when using TransferText in MS Access 2000. I am exporting a query to a text file using TransferText in a module. One of my fields is a text field called "invoice description". This field may include any content including dates (e.g., 01/01/2006, 1/1/2006, 01/01/06, Invoice #1, Jan 2006, 293842, etc. are all
0
423
by: stuart | last post by:
I seem to have a problem with the use of the TransferText function. In 2 applications that I have, every few months, it seems to not export a few records from a table. In another application, every 2-3 months the users would start getting run time errors after they exported data from my program. Is anyone aware of problems with this function with these kind of results. The following is a code fragement:
7
6029
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
9711
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
9591
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
10594
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
10331
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,...
0
10087
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7631
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
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
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
3001
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.