469,354 Members | 2,321 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,354 developers. It's quick & easy.

TransferText method msaccess - Imported table corrupted

I'm trying to import some text files in a simple access table, but
sometimes it miss some rows after import.
here is the code:
Public Function OpenMyApplicationData() As Boolean
Dim Upid As Boolean
Dim LastBD As Integer
Dim dbs As Database
Dim fileN As String
Dim tableN As String
Set dbs = CurrentDb
On Error GoTo Err_OpenMyApplicationData
Dim strMyApplicationDataFile As String
Dim strExitMessage As String
'windows common dialog- open file mode
strMyApplicationDataFile = OpenSaveCommonDialog("Open",
GetAppDir() & "MyDataSubdirectory", _
"Open MyApplication Data Files", "",
"MyApplication Data Files(*.txt)", "*.txt")
LastBD = find_last(strMyApplicationDataFile, "\")
fileN = "#" + Mid(strMyApplicationDataFile, LastBD + 1)
tableN = Mid(strMyApplicationDataFile, LastBD + 1,
Len(Mid(strMyApplicationDataFile, LastBD + 1)) - 4)
'test response
If (strMyApplicationDataFile = "") Then
OpenMyApplicationData = False
strExitMessage = "Attempt to open MyApplication Data Files
'import the text file
OpenMyApplicationData = True
strExitMessage = ""
dbs.Execute ("DELETE * FROM pivoti;")
DoCmd.TransferText acImportFixed, "ImpSpec", "pivoti",
strMyApplicationDataFile, False
dbs.Execute ("DELETE * FROM pivoti WHERE field1 = '' or
field1 is NULL;")
' dbs.Execute ("UPDATE pivoti set ID=count(*);")
dbs.Execute ("INSERT INTO pivoti (ID,field1) values (1,'" +
fileN + "');")
Upid = Update_ID
dbs.Execute ("loadprop")
MsgBox "Table loaded correctly!"

End If
If Not (OpenMyApplicationData) Then
MsgBox strExitMessage, vbInformation, "MyApplication Software"
End If
Exit Function

'on error fail the function
OpenMyApplicationData = False
strExitMessage = "Error during attempt to open MyApplication
Data Files (error# " & Err.Number & " " & Err.Description & ")"
Resume Exit_OpenMyApplicationData
End Function

the missing part (example)
SYMPATHIE=Simpatia <--- imported

RELEVES=Estratti conto
BOUCLEMENT=Chiusura processo
COM_BOUCLEMENT=Commissioni su chiusura processo
COM_MOUVEMENT=Commissioni su movimenti
APPL_TARIF=Prezzo applicato
Y/N=Y/N* (*:Par defaut)
YN = Y/N* (*:Par defaut)

LIBFEES=Commissioni su chiusura processo
DEBITMAX=Addebito massimo
DEBITMOY=Addebito medio
TOTALDEB=Totale addebiti
MARGEPLFD=Margine massimo
PLAFOND=Su massimo
DEPASPLFD=Massimo superato
METHODE=Metodo 5+6
CREDITMOY=Accredito medio

#ACCOUNT_INTERESTS <---- imported

thank you for helping

Nov 13 '05 #1
0 1045

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Vladislav Moltchanov | last post: by
12 posts views Thread by ckirby | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.