D
david h diamond
The following is the boiled down version of a real-world problem.
I have two .csv files, workbook1 and workbookq
Workbook1 consists of 1 line, 1 field:
xxxxx
WorkbookQ consists of 2 lines, 1 field:
xxxxx
75104
I used the following code (copied from somewhere in microsoft.com) to link
to the two files.
Function LinkSchema()
Dim db As DAO.Database, tbl As DAO.TableDef, tblQ As DAO.TableDef
Set db = CurrentDb()
'*
Set tbl = db.CreateTableDef("workbook1")
tbl.Connect = "Text;DATABASE=C:\bugchaser;TABLE=workbook1.csv"
tbl.SourceTableName = "workbook1.csv"
db.TableDefs.Append tbl
db.TableDefs.Refresh
'*
Set tbl = db.CreateTableDef("workbookQ")
tbl.Connect = "Text;DATABASE=C:\bugchaser;TABLE=workbookQ.csv"
tbl.SourceTableName = "workbookQ.csv"
db.TableDefs.Append tbl
db.TableDefs.Refresh
End Function
The resulting tables are:
- Workbook1
xxxxx
- WorkbookQ
#Num!
75104
I interpret this to mean that Access is assuming that if there is a number
in a column, the field is numeric.
In the past I got round this by making the first row contain a non-numeric,
but, as you see, this does not work here.
Even if I use other methods to import into a file def where Fred is defined
as text, I get a similar result.
I am getting desperate enough to think of using excel to massage the file
before importing it to Access - it does not get much uglier than that!
I don't know if this is a bug or a feature. I do know it is a nuisance.
If anyone can shed light on this one, it would be of great help
I have two .csv files, workbook1 and workbookq
Workbook1 consists of 1 line, 1 field:
xxxxx
WorkbookQ consists of 2 lines, 1 field:
xxxxx
75104
I used the following code (copied from somewhere in microsoft.com) to link
to the two files.
Function LinkSchema()
Dim db As DAO.Database, tbl As DAO.TableDef, tblQ As DAO.TableDef
Set db = CurrentDb()
'*
Set tbl = db.CreateTableDef("workbook1")
tbl.Connect = "Text;DATABASE=C:\bugchaser;TABLE=workbook1.csv"
tbl.SourceTableName = "workbook1.csv"
db.TableDefs.Append tbl
db.TableDefs.Refresh
'*
Set tbl = db.CreateTableDef("workbookQ")
tbl.Connect = "Text;DATABASE=C:\bugchaser;TABLE=workbookQ.csv"
tbl.SourceTableName = "workbookQ.csv"
db.TableDefs.Append tbl
db.TableDefs.Refresh
End Function
The resulting tables are:
- Workbook1
xxxxx
- WorkbookQ
#Num!
75104
I interpret this to mean that Access is assuming that if there is a number
in a column, the field is numeric.
In the past I got round this by making the first row contain a non-numeric,
but, as you see, this does not work here.
Even if I use other methods to import into a file def where Fred is defined
as text, I get a similar result.
I am getting desperate enough to think of using excel to massage the file
before importing it to Access - it does not get much uglier than that!
I don't know if this is a bug or a feature. I do know it is a nuisance.
If anyone can shed light on this one, it would be of great help