Getting data from a file

  • Thread starter Thread starter joten
  • Start date Start date
J

joten

Hello I'll try to explain you a problem that I have with my database.
I have a file (FILE.TXT) with the following fields:
INVOICE-AMOUNT-CUSTOMER-DATE
I'm trying to as data are read from the file, the records that fulfil
a condition they are added to a table with the same fields that abov
mentioned.
In order to directly add data in a table, before I have used thi
code:

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = CodeProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Source = "TABLENAME"
.Open options = adCmdTableDirect
.AddNew
!invoice = file.invoice
!amount = file.amount
!customer = file.customer
!date = file.date
.Update
.Close
End With
Set rst = Nothing

The problem that I have now is that I don't know where in the abov
code, to include the code that it allows to me to get records from th
file and to verify if they fulfill the necessary conditions.
The code is something like this:

Open "c:\file.txt" For Random As #1 Len = 82
For i = 1 To LOF(1) / 82
Get #1, i, recordfile
If ........ Then
Else
End If
Next

Thank you in advance
 
Hi Joten,

I woudln't use recordset operations for this. Instead, I'd use File|Get
External Data|Link to link to the text file, and then use an Append
query to select the records that meet the condition from this linked
table and append them to the main table.
 
Back
Top