niki
axes noob 'll b big 1 day
- Local time
- Today, 23:13
- Joined
- Apr 17, 2003
- Messages
- 66
Hello,
I want to have a button dedicated to importing text files into tables on a click. Here's the code I was given but I can"t manage to have it work. Both of my field are memo type is there a special declaration for this type of fields? Is the String type OK for this type of fields?
Is it possible to modify the script so that multiple text files with identical structures (number of fields, field names...) be imported in different tables with also identical structures?
Thanks for your help!
cheers
nico
I want to have a button dedicated to importing text files into tables on a click. Here's the code I was given but I can"t manage to have it work. Both of my field are memo type is there a special declaration for this type of fields? Is the String type OK for this type of fields?
Is it possible to modify the script so that multiple text files with identical structures (number of fields, field names...) be imported in different tables with also identical structures?
Thanks for your help!
cheers
nico
Code:
Dim dbs As DataBase
Dim rst As Recordset
Dim sql As String
Dim buf As String
Dim ptr As long
Dim Delimiter As String
Delimiter = Chr(ASC(181)) ' for "µ" delimiter
Set dbs = CurrentDb
sql = "Select * from YourTable"
Set rst = dbs.OpenRecordset(sql)
Open "C:\Prop_Aero.txt" For Input As #1
Line Input #1, buf
While Not EOF(1)
ptr = 1
'
Col1 = ""
While(Mid(buf, ptr, 1) <> Delimiter)
Col1 = Col1 & Mid(buf, ptr, 1)
ptr = ptr + 1
Wend
ptr = ptr + 1
'
Col2 = ""
While(Mid(buf, ptr, 1) <> Delimiter)
Col2 = Col2 & Mid(buf, ptr, 1)
ptr = ptr + 1
Wend
ptr = ptr + 1
'
rst.Addnew
rst!Collaboration = Col1
rst!ContactPerson = Col2
rst.Update
Line Input #1, buf
Wend