From: DS on
I'm trying to export a table to a txt file, the export works fine.

'Export
Private Sub Command0_Click()
DoCmd.TransferText acExportDelim, , "Table1", "c:\Access\export.txt"
End Sub


The problem is when I try to import back into the table, it keeps asking
for a field that does't exist. Any help appreciated.


'Import
Private Sub Command1_Click()
DoCmd.TransferText acImportDelim, , "Table1", "C:\Access\Export.txt"
End Sub

Thanks
DS
From: John Nurick on
When you're importing to an existing table, the field names in the
source must match the field names in the destination.

Your export statement creates a text file without field names; and when
the import routine encounters this it assigns default field names F1,
F2... - and then panics when these don't match the names in the table
you're importing to.

The simplest solution is to use the HasFieldNames argument of
TransferText to ensure that the field names are used when exporting or
importing.

On Wed, 15 Mar 2006 11:28:16 -0500, DS <bootybox(a)optonline.net> wrote:

>I'm trying to export a table to a txt file, the export works fine.
>
>'Export
>Private Sub Command0_Click()
> DoCmd.TransferText acExportDelim, , "Table1", "c:\Access\export.txt"
>End Sub
>
>
>The problem is when I try to import back into the table, it keeps asking
>for a field that does't exist. Any help appreciated.
>
>
>'Import
>Private Sub Command1_Click()
> DoCmd.TransferText acImportDelim, , "Table1", "C:\Access\Export.txt"
>End Sub
>
>Thanks
>DS

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.

From: DS on
John Nurick wrote:
> When you're importing to an existing table, the field names in the
> source must match the field names in the destination.
>
> Your export statement creates a text file without field names; and when
> the import routine encounters this it assigns default field names F1,
> F2... - and then panics when these don't match the names in the table
> you're importing to.
>
> The simplest solution is to use the HasFieldNames argument of
> TransferText to ensure that the field names are used when exporting or
> importing.
>
> On Wed, 15 Mar 2006 11:28:16 -0500, DS <bootybox(a)optonline.net> wrote:
>
>
>>I'm trying to export a table to a txt file, the export works fine.
>>
>>'Export
>>Private Sub Command0_Click()
>> DoCmd.TransferText acExportDelim, , "Table1", "c:\Access\export.txt"
>>End Sub
>>
>>
>>The problem is when I try to import back into the table, it keeps asking
>>for a field that does't exist. Any help appreciated.
>>
>>
>>'Import
>>Private Sub Command1_Click()
>> DoCmd.TransferText acImportDelim, , "Table1", "C:\Access\Export.txt"
>>End Sub
>>
>>Thanks
>>DS
>
>
> --
> John Nurick [Microsoft Access MVP]
>
> Please respond in the newgroup and not by email.
>
Thanks, I'm getting closer.
So if I had fields F1, F2 and F3 then it would look like this?

DoCmd.TransferText acImportDelim, , "Table1", "C:\Access\Export.Txt",
F1, F2, F3


Thanks again,
DS
From: John Nurick on
No. TransferText doesn't care what the field names are.

When you export the data, use something like this, passing -1 or True as
the HasFieldNames argument:

DoCmd.TransferText acExportDelim, , "Table1", "c:\Access\export.txt", -1

That means that the first row of the text file will contain the field
names.

Then, when you import, use something like this:

DoCmd.TransferText acImportDelim, , "Table1", "C:\Access\Export.txt", -1

and Access will use use the field names in the text file to match its
fields with those in the existing table.

On Wed, 15 Mar 2006 14:48:42 -0500, DS <bootybox(a)optonline.net> wrote:
>Thanks, I'm getting closer.
>So if I had fields F1, F2 and F3 then it would look like this?
>
>DoCmd.TransferText acImportDelim, , "Table1", "C:\Access\Export.Txt",
>F1, F2, F3
>
>
>Thanks again,
>DS
>John Nurick wrote:
>> When you're importing to an existing table, the field names in the
>> source must match the field names in the destination.
>>
>> Your export statement creates a text file without field names; and when
>> the import routine encounters this it assigns default field names F1,
>> F2... - and then panics when these don't match the names in the table
>> you're importing to.
>>
>> The simplest solution is to use the HasFieldNames argument of
>> TransferText to ensure that the field names are used when exporting or
>> importing.
>>
>> On Wed, 15 Mar 2006 11:28:16 -0500, DS <bootybox(a)optonline.net> wrote:
>>
>>
>>>I'm trying to export a table to a txt file, the export works fine.
>>>
>>>'Export
>>>Private Sub Command0_Click()
>>> DoCmd.TransferText acExportDelim, , "Table1", "c:\Access\export.txt"
>>>End Sub
>>>
>>>
>>>The problem is when I try to import back into the table, it keeps asking
>>>for a field that does't exist. Any help appreciated.
>>>
>>>
>>>'Import
>>>Private Sub Command1_Click()
>>> DoCmd.TransferText acImportDelim, , "Table1", "C:\Access\Export.txt"
>>>End Sub
>>>
>>>Thanks
>>>DS
>>
>>
>> --
>> John Nurick [Microsoft Access MVP]
>>
>> Please respond in the newgroup and not by email.
>>


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.

From: DS on
John Nurick wrote:
> No. TransferText doesn't care what the field names are.
>
> When you export the data, use something like this, passing -1 or True as
> the HasFieldNames argument:
>
> DoCmd.TransferText acExportDelim, , "Table1", "c:\Access\export.txt", -1
>
> That means that the first row of the text file will contain the field
> names.
>
> Then, when you import, use something like this:
>
> DoCmd.TransferText acImportDelim, , "Table1", "C:\Access\Export.txt", -1
>
> and Access will use use the field names in the text file to match its
> fields with those in the existing table.
>
> On Wed, 15 Mar 2006 14:48:42 -0500, DS <bootybox(a)optonline.net> wrote:
>
>>Thanks, I'm getting closer.
>>So if I had fields F1, F2 and F3 then it would look like this?
>>
>>DoCmd.TransferText acImportDelim, , "Table1", "C:\Access\Export.Txt",
>>F1, F2, F3
>>
>>
>>Thanks again,
>>DS
>>John Nurick wrote:
>>
>>>When you're importing to an existing table, the field names in the
>>>source must match the field names in the destination.
>>>
>>>Your export statement creates a text file without field names; and when
>>>the import routine encounters this it assigns default field names F1,
>>>F2... - and then panics when these don't match the names in the table
>>>you're importing to.
>>>
>>>The simplest solution is to use the HasFieldNames argument of
>>>TransferText to ensure that the field names are used when exporting or
>>>importing.
>>>
>>>On Wed, 15 Mar 2006 11:28:16 -0500, DS <bootybox(a)optonline.net> wrote:
>>>
>>>
>>>
>>>>I'm trying to export a table to a txt file, the export works fine.
>>>>
>>>>'Export
>>>>Private Sub Command0_Click()
>>>> DoCmd.TransferText acExportDelim, , "Table1", "c:\Access\export.txt"
>>>>End Sub
>>>>
>>>>
>>>>The problem is when I try to import back into the table, it keeps asking
>>>>for a field that does't exist. Any help appreciated.
>>>>
>>>>
>>>>'Import
>>>>Private Sub Command1_Click()
>>>> DoCmd.TransferText acImportDelim, , "Table1", "C:\Access\Export.txt"
>>>>End Sub
>>>>
>>>>Thanks
>>>>DS
>>>
>>>
>>>--
>>>John Nurick [Microsoft Access MVP]
>>>
>>>Please respond in the newgroup and not by email.
>>>
>
>
>
> --
> John Nurick [Microsoft Access MVP]
>
> Please respond in the newgroup and not by email.
>
Thnaks, I've got it now! Finally!
Thanks
DS