OK!
So that´s why I got the runtime error!
Thank´s for explaining and beeing patiant with me ;-)
Thank´s a lot Ken!
// Niklas
"Ken Snell [MVP]" <
[email protected]> skrev i
meddelandet
OK - Now I understand.
The problem you're having is that you're trying to import data into a
table
that has an autonumber field as the first field, and your text file does
not
have that field in its record. Your text file begins with the field that
is
the second field in the table. Thus, ACCESS is "off by one field" for your
data, as it's using the first field in your text file to put data
into the
autonumber data field.
Import the data into a temporary table, and then use an append query to
copy
the imported data into your permanent table.
--
Ken Snell
<MS ACCESS MVP>
This is the syntax for DoCmd.TransferText:
TransferText([TransferType As AcTextTransferType = acImportDelim],
[SpecificationName], [TableName], [FileName], [HasFieldNames],
[HTMLTableName], [CodePage]
And in helpfile it says that [SpecificationName] is optional
(SpecificationName Optional Variant. A string expression that's
the
name
of
an ...)
And I left it out in my code:
DoCmd.TransferText acImportDelim, , "tblPerson",
"C:/Program/Tuffa
Viktor/ExportedDocs/tblPerson.txt", False
Mostly because I don´t understand how to use it or what´s good with it.
So
I
guess that this is my Q. How shall I use it and what´s it good for?
I´m sorry for the inconvenience of me beeing unclear with my Q.
Thank´s for puting in so much time into my problem anyway. I do
appreciate
it!
// Niklas
"Ken Snell [MVP]" <
[email protected]> skrev i meddelandet
I'm sorry, I don't understand. "Optional part which [you] left out"?
What
specifically is the question?
--
Ken Snell
<MS ACCESS MVP>
Aha, I get it!
This is the optional part which I left out. But how am I going to
use
this
to specify how my table looks like?
I have looked in help file for this but I may be a little bit slow
here.
I
just can´t understand how to apply this on my example?
// Niklas
"Ken Snell [MVP]" <
[email protected]> skrev i
meddelandet
The F1 field is coming from the import specification, details
about
which
you did not post....
--
Ken Snell
<MS ACCESS MVP>
Sorry!
My table looks like this:
tblPerson
[PersonID]: AutoNumber, Primary key
[fkNewMemberShipEntryID]: Long integer
[FirstName]: String of max 30 charachters
[LastName]: String of max 30 charachters
...... etc.
An the textfile looks like this:
2;;"Niklas";"Östergren";"Nicke";1965-05-01