Trouble With Import (Spec?) (1 Viewer)

catbeasy

Registered User.
Local time
Today, 07:54
Joined
Feb 11, 2009
Messages
140
Hi

I have been importing files for a good while using the import spec feature and the docmd.transfertext command in Access97.

However, in all of these, the files I've been importing have all had fields in the first row. This new text file I'm importing doesn't and I don't know if that has something to do with the trouble I'm experiencing:

When I use the below code to import the file, it gives me only 2 of the 3 records in the text file.

However, when I step through the import by going to file-->import and using the import text wizard, I get the 3 records. And I get the 3 records using the Import Spec or without using it. Funny thing is, when using the Import Spec by clicking on Advanced-->Specs--> and then opening the Import Spec I created (the one used in the transfertext function - btw, its the only spec I have in this database) and using that to step through the import using the Import Text wizard, at the very end when I click Finish, it tells me my Import Spec has changed, when, in fact, I haven't changed anything.

Something tells me that stepping through this thing though, does in fact, change something and that something allows all 3 records to come through.

btw, even after I say "Yes" to the Import Spec change and immediately after that try running the code, it still only imports the 2 records. So, even though I saved the changes, if my above reasoning is correct, they weren't really saved?

In any case, I don't know what's going on, these are just guesses. Is there perhaps a switch somewhere where I have to tell it to import the first line/record if the first line/record doesn't contain field names?

Any help is appreciated..here is the code:

Public Function fcn_Import_File()
Dim strFP As String
Dim strFN As String
Dim strFPFN As String
Dim strImportSpecName As String
Dim strTblName As String

DoCmd.DeleteObject acTable, "tbl_Mbr_PDP_Import_SD"

strFP = "c\:"
strFN = "data.txt"
strFPFN = strFP & strFN
strImportSpecName = "IS_DL_Data"
strTblName = "tbl_Mbr_PDP_Import_SD"

DoCmd.TransferText acImportDelim, strImportSpecName, strTblName, strFPFN, -1
End Function
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 15:54
Joined
Sep 12, 2006
Messages
15,700
one of the parameters in transfertext is HasFieldNames - that's the one you need.
 

Users who are viewing this thread

Top Bottom