Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Export to TXT file

 
   Database Forums (Home) -> MS Access RSS
Next:  DISTRIBUTED TRANSACTION PROBLEM  
Author Message
pnas

External


Since: Jan 15, 2008
Posts: 1



(Msg. 1) Posted: Tue Jan 15, 2008 1:29 am
Post subject: Export to TXT file
Archived from groups: microsoft>public>access (more info?)

I have a table that i need to export to a txt file and the problem is when i
convert to txt a decimal number like 23,343667 it export to txt only 23,34.

--
pnas

 >> Stay informed about: Export to TXT file 
Back to top
Login to vote
Jamie Collins

External


Since: Nov 30, 2007
Posts: 136



(Msg. 2) Posted: Tue Jan 15, 2008 3:37 am
Post subject: Re: Export to TXT file [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Jan 15, 10:43 am, "Jeanette Cunningham"
wrote:
> Access 2003
> There is a way to get the numbers to export with more than 2 decimal places
> --save the table as a query
> --create a calculated field for the number with more than 2 decimalplaces
> for example
> if you want 6 decimal places, in an empty field in the query type
> A:Format([YourNumberField], "0,000000")
>
> --unfortunately this method gives all the numbers exactly the number of decimal places specified in the format
> --if your number originally was 23.156 it would be exported as 23.156000

That would export the data as text, could round values (and do you
know which rounding algorithm?), etc. Perhaps better to work with the
raw data Smile

Use a schema.ini file to specify data types or simply get the engine
to generate one for you e.g. ANSI-92 Query Mode syntax:

CREATE TABLE Test (
dec_col DECIMAL(10, 5) NOT NULL
)
;
INSERT INTO Test (dec_col) VALUES (12345.6789)
;
INSERT INTO Test (dec_col) VALUES (9876.54321)
;
SELECT dec_col
INTO [TEXT;Database=C:\;].NewFile#txt
FROM Test
;

The generated file named 'NewFile.txt' contains this data:

"dec_col"
12345.6789
9876.54321

The generated schema.ini file (but could have been created manually in
order to be different from the mdb's schema if desired) contains the
following information schema:

[NewFile.txt]
ColNameHeader=True
CharacterSet=1252
Format=CSVDelimited
Col1=dec_col Decimal Precision 10 Scale 5

Jamie.

--

 >> Stay informed about: Export to TXT file 
Back to top
Login to vote
Jeanette Cunningham

External


Since: Dec 15, 2007
Posts: 56



(Msg. 3) Posted: Tue Jan 15, 2008 11:03 am
Post subject: Re: Export to TXT file [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Access 2003
There is a way to get the numbers to export with more than 2 decimal places
--save the table as a query
--create a calculated field for the number with more than 2 decimal places
for example
if you want 6 decimal places, in an empty field in the query type
A:Format([YourNumberField], "0,000000")
0 is for all numbers to the left of the decimal place holder
000000 is for 6 decimal places, change the number of zeros to suit

--export the query instead of the table
--unfortunately this method gives all the numbers exactly the number of
decimal places specified in the format
--if your number originally was 23.156 it would be exported as 23.156000

I didn't realise that Access 2003 always cut numbers to 2 decimal places
when exporting a table to .txt format.
That is not very useful.

Jeanette Cunningham

"pnas" wrote in message

>I have a table that i need to export to a txt file and the problem is when
>i
> convert to txt a decimal number like 23,343667 it export to txt only
> 23,34.
>
> --
> pnas
 >> Stay informed about: Export to TXT file 
Back to top
Login to vote
Jeanette Cunningham

External


Since: Dec 15, 2007
Posts: 56



(Msg. 4) Posted: Tue Jan 15, 2008 11:03 am
Post subject: Re: Export to TXT file [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

There is a better way to do this.
You still need to save the table as a query.
Use a calculated field
In an empty column in the query type this:
B: IIf(Len([YourNumberField])>0,CStr([YourNumberField]),"")

--B is the new name for this calculated field ( you can give a different
name)
--converting the number to a text string saves the correct number of decimal
places for each number
--export the query

Jeanette Cunningham

"pnas" wrote in message

>I have a table that i need to export to a txt file and the problem is when
>i
> convert to txt a decimal number like 23,343667 it export to txt only
> 23,34.
>
> --
> pnas
 >> Stay informed about: Export to TXT file 
Back to top
Login to vote
Jeanette Cunningham

External


Since: Dec 15, 2007
Posts: 56



(Msg. 5) Posted: Tue Jan 15, 2008 3:02 pm
Post subject: Re: Export to TXT file [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks Jamie

Jeanette Cunningham

"Jamie Collins" wrote in message

> On Jan 15, 10:43 am, "Jeanette Cunningham"
> wrote:
>> Access 2003
>> There is a way to get the numbers to export with more than 2 decimal
>> places
>> --save the table as a query
>> --create a calculated field for the number with more than 2 decimalplaces
>> for example
>> if you want 6 decimal places, in an empty field in the query type
>> A:Format([YourNumberField], "0,000000")
>>
>> --unfortunately this method gives all the numbers exactly the number of
>> decimal places specified in the format
>> --if your number originally was 23.156 it would be exported as 23.156000
>
> That would export the data as text, could round values (and do you
> know which rounding algorithm?), etc. Perhaps better to work with the
> raw data Smile
>
> Use a schema.ini file to specify data types or simply get the engine
> to generate one for you e.g. ANSI-92 Query Mode syntax:
>
> CREATE TABLE Test (
> dec_col DECIMAL(10, 5) NOT NULL
> )
> ;
> INSERT INTO Test (dec_col) VALUES (12345.6789)
> ;
> INSERT INTO Test (dec_col) VALUES (9876.54321)
> ;
> SELECT dec_col
> INTO [TEXT;Database=C:\;].NewFile#txt
> FROM Test
> ;
>
> The generated file named 'NewFile.txt' contains this data:
>
> "dec_col"
> 12345.6789
> 9876.54321
>
> The generated schema.ini file (but could have been created manually in
> order to be different from the mdb's schema if desired) contains the
> following information schema:
>
> [NewFile.txt]
> ColNameHeader=True
> CharacterSet=1252
> Format=CSVDelimited
> Col1=dec_col Decimal Precision 10 Scale 5
>
> Jamie.
>
> --
>
 >> Stay informed about: Export to TXT file 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
export and open an excel file from access - dear friends can any one please help me one more thing please for which im looking over whole news group! (1) i want to export many querys to excel using outputto method ofcourse its doing the job but its creating an new work sheet for every query ...

Faulty Object Export - This has been bugging me for months. I am running an Access app on a LAN. I am still building it so I add or edit features often. When i have something right I send it to users via the File, Export command. I get the warning that the object exists and...

RTF export issue - Each time I attempt to export a report to Word (RTF) or HTML, Access 2007 either takes forever (> 20 minutes) or doesn't work at all. Text export works fine. This has been replicated on 2 different computers, one on XP, one on vista. Has anybody el...

overflow during ODBC export - OK, I've been watching my DB grow and have known for a long time I would have to move the back end, but of course I waited until I started getting odd behavior (at about 1.92GB). So today I installed MySQL and (after a bit too much time getting the data....

export query to excel and do calculations - dear friends, i have a table name "dutyroster" field employeename " onduty " offduty " date now i would like to transfer the query output of emloyeename , onduty , offduty , date, to excel file using...
   Database Forums (Home) -> MS Access All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]