truncate zero in the starting when importing from text file

M

Mohsin Habib

Hi,
I am importing data from text file, it has the field of telephone numbers,
but access truncate all the zeros in the starting. I have set the field type
as Text but still it is not working (although its work when I manually type
data in that field but does not work while importing). I need to display all
the zeros in the field to distinguish local and international calls. Please
help if someone knows the solution.
 
R

Rick Brandt

Mohsin said:
Hi,
I am importing data from text file, it has the field of telephone
numbers, but access truncate all the zeros in the starting. I have
set the field type as Text but still it is not working (although its
work when I manually type data in that field but does not work while
importing). I need to display all the zeros in the field to
distinguish local and international calls. Please help if someone
knows the solution.

When you import a text file an import specification is created. During that
process Access will examine the data on the first few lines and make assumptions
about the data type for each field. While in the import wizard you should have
a step where YOU can specify the data types on each field instead of allowing
the assumptions. You need to specify text on that field.
 
M

Mohsin Habib

Actually I am importing the data in Access using VB 6.0, for this I have
first created table in Access and then write code in VB to import data in
it...

code is look like this
-----------------------------
strCn = "Driver={Microsoft Text Driver (*.txt; *.csv)} ;" & _
"DBQ=" & App.Path & ";" & _
"DefaultDir=" & App.Path & ";"

Set adoCn = New ADODB.Connection
adoCn.Open strCn

strSQL = "INSERT INTO [" & txtTable.Text & "] IN '" & App.Path & "\Table.mdb
'"
strSQL = strSQL & "SELECT * FROM " & txtFile.Text
adoCn.Execute strSQL
----------------------------

code is working but I am experiencing the probelm which I have mention in my
question...... So I cant check it during the process of importing as it is
automated....
Is there any solution for it??????
 
J

Jamie Collins

Actually I am importing the data in Access using VB 6.0, for this I have
first created table in Access and then write code in VB to import data

You seem to be using Jet, not Access, therefore use a schema.ini file
(google it) to define the data types.

Import specs = Access, not Jet
schema.ini file = Jet

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top