PC Review


Reply
Thread Tools Rate Thread

change datatype of a fieldname by code

 
 
geert.van.ransbeeck@telenet.be
Guest
Posts: n/a
 
      23rd Jan 2009
Hello
I just imported a csv-document into an new access table.
Every fieldname has been correctly imported except for one. In this
field I need a text field instead of a number. The data is like
09078978979, 09077879000, etc... so it is logical he detects it as a
number leaving the first 0. For me it's important that the first 0
doesn't disappear. Text datatype would be ok. How can I preserve the
0, so how can I change this field into text by code.
thabks a lot for your suggestion.

kind regards
geert
 
Reply With Quote
 
 
 
 
pietlinden@hotmail.com
Guest
Posts: n/a
 
      23rd Jan 2009
On Jan 23, 4:45*pm, geert.van.ransbe...@telenet.be wrote:
> Hello
> I just imported a csv-document into an new access table.
> Every fieldname has been correctly imported except for one. In this
> field I need a text field instead of a number. The data is like
> 09078978979, 09077879000, etc... so it is logical he detects it as a
> number leaving the first 0. For me it's important that the first 0
> doesn't disappear. Text datatype would be ok. How can I preserve the
> 0, so how can I change this field into text by code.
> thabks a lot for your suggestion.
>
> kind regards
> geert


If the fields in your data are consistent, why not just create a table
that you can import into, create an import specification which you use
in your TransferText command? Then since the table's structure is
constant, your problems should go away.
 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      24th Jan 2009
On Fri, 23 Jan 2009 14:45:43 -0800 (PST), (E-Mail Removed)
wrote:

>Hello
>I just imported a csv-document into an new access table.
>Every fieldname has been correctly imported except for one. In this
>field I need a text field instead of a number. The data is like
>09078978979, 09077879000, etc... so it is logical he detects it as a
>number leaving the first 0. For me it's important that the first 0
>doesn't disappear. Text datatype would be ok. How can I preserve the
>0, so how can I change this field into text by code.
>thabks a lot for your suggestion.
>
>kind regards
>geert


Your problems may be worse than you think: Long Integers are limited to 2^31,
two billion odd - and your numbers are bigger than that. What is the datatype
of the imported field?

Piet's suggestion is right on the mark - *link* to this CSV file and run an
Append query into a predefined table with the appropriate datatypes.
--

John W. Vinson [MVP]
 
Reply With Quote
 
geert.van.ransbeeck@telenet.be
Guest
Posts: n/a
 
      24th Jan 2009
On 24 jan, 02:50, John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com>
wrote:
> On Fri, 23 Jan 2009 14:45:43 -0800 (PST), geert.van.ransbe...@telenet.be
> wrote:
>
> >Hello
> >I just imported a csv-document into an new access table.
> >Every fieldname has been correctly imported except for one. In this
> >field I need a text field instead of a number. The data is like
> >09078978979, 09077879000, etc... so it is logical he detects it as a
> >number leaving the first 0. For me it's important that the first 0
> >doesn't disappear. Text datatype would be ok. How can I preserve the
> >0, so how can I change this field into text by code.
> >thabks a lot for your suggestion.

>
> >kind regards
> >geert

>
> Your problems may be worse than you think: Long Integers are limited to 2^31,
> two billion odd - and your numbers are bigger than that. What is the datatype
> of the imported field?
>
> Piet's suggestion is right on the mark - *link* to this CSV file and run an
> Append query into a predefined table with the appropriate datatypes.
> --
>
> * * * * * * *John W. Vinson [MVP]


Thanks a lot but how can I append my lost 0 to this new table?
 
Reply With Quote
 
geert.van.ransbeeck@telenet.be
Guest
Posts: n/a
 
      24th Jan 2009
On 24 jan, 02:50, John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com>
wrote:
> On Fri, 23 Jan 2009 14:45:43 -0800 (PST), geert.van.ransbe...@telenet.be
> wrote:
>
> >Hello
> >I just imported a csv-document into an new access table.
> >Every fieldname has been correctly imported except for one. In this
> >field I need a text field instead of a number. The data is like
> >09078978979, 09077879000, etc... so it is logical he detects it as a
> >number leaving the first 0. For me it's important that the first 0
> >doesn't disappear. Text datatype would be ok. How can I preserve the
> >0, so how can I change this field into text by code.
> >thabks a lot for your suggestion.

>
> >kind regards
> >geert

>
> Your problems may be worse than you think: Long Integers are limited to 2^31,
> two billion odd - and your numbers are bigger than that. What is the datatype
> of the imported field?
>
> Piet's suggestion is right on the mark - *link* to this CSV file and run an
> Append query into a predefined table with the appropriate datatypes.
> --
>
> * * * * * * *John W. Vinson [MVP]


Thanks a lot but how can I append my lost 0 to this new table?
 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      24th Jan 2009
On Sat, 24 Jan 2009 02:27:53 -0800 (PST), (E-Mail Removed)
wrote:

>On 24 jan, 02:50, John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com>
>wrote:
>> On Fri, 23 Jan 2009 14:45:43 -0800 (PST), geert.van.ransbe...@telenet.be
>> wrote:
>>
>> >Hello
>> >I just imported a csv-document into an new access table.
>> >Every fieldname has been correctly imported except for one. In this
>> >field I need a text field instead of a number. The data is like
>> >09078978979, 09077879000, etc... so it is logical he detects it as a
>> >number leaving the first 0. For me it's important that the first 0
>> >doesn't disappear. Text datatype would be ok. How can I preserve the
>> >0, so how can I change this field into text by code.
>> >thabks a lot for your suggestion.

>>
>> >kind regards
>> >geert

>>
>> Your problems may be worse than you think: Long Integers are limited to 2^31,
>> two billion odd - and your numbers are bigger than that. What is the datatype
>> of the imported field?
>>
>> Piet's suggestion is right on the mark - *link* to this CSV file and run an
>> Append query into a predefined table with the appropriate datatypes.
>> --
>>
>> * * * * * * *John W. Vinson [MVP]

>
>Thanks a lot but how can I append my lost 0 to this new table?


You can run an Update query updating the field to

Right("00000000000" & [fieldname], 11)

to append eleven zeros to the start of the field, and then take the last
eleven bytes of the result; this will append zero, one, two or however many
leading zeroes are needed.
--

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change FieldName ooxx Microsoft Access Form Coding 4 25th Nov 2008 05:33 AM
Reading an AutoNum fieldname and changing its datatype to Number =?Utf-8?B?TEY=?= Microsoft Access Form Coding 4 11th Jul 2007 04:42 PM
Change field datatype code =?Utf-8?B?bWFyY28=?= Microsoft Access VBA Modules 6 9th Jun 2005 11:20 PM
Change a fieldname =?Utf-8?B?TWFyaw==?= Microsoft Access VBA Modules 1 19th Apr 2005 09:36 PM
Change datatype table field in code =?Utf-8?B?TWFyY28=?= Microsoft Access Form Coding 1 14th Jan 2005 11:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:34 AM.