NEED TO READ DATA FROM A TEXT FILE AND PUT IT INTO AN ACCESS TABLE 
Author Message
 NEED TO READ DATA FROM A TEXT FILE AND PUT IT INTO AN ACCESS TABLE

I need code to pull data from a text file and input it into an access table
using visal basics......help!


Sun, 22 Sep 2002 03:00:00 GMT  
 NEED TO READ DATA FROM A TEXT FILE AND PUT IT INTO AN ACCESS TABLE


Quote:
> I need code to pull data from a text file and input it into an access
table
> using visal basics......help!

Did you know you can read in from a textfile from whitin MS Acces?

But you asked for code:
this is not tested, i just typed it to give you my idea of how code would
look like.
Also you can use a data control to lookup a textfile as a table and from
there update your Acces database.
(but that did pain to me to figure out the datacontrol properties settings
etc)

assuming you have ; as field separator in your text file:

    Dim x As Long, y As Long
    Dim sTmp1 As String, sTmp2 As String, sTmp3 As String

    Dim rsNew As Recordset

    y = 1
    Open impFile For Input As #1
    Do Until EOF(1)
        Line Input #1, sTmp1
        rsNew.AddNew
        For x = 1 To Len(sTmp1)
            sTmp2 = Mid(sTmp1, x, 1)
            If sTmp2 <> Chr$(59) Then
                sTmp3 = sTmp3 & sTmp2
            Else
                If y = 1 Then sTmp3 = CLng(sTmp3)
                    rsNew.Fields(y).Value = LTrim(RTrim(sTmp3))
                    sTmp3 = ""
                If y < InStr(sTmp1, Chr$(59)) Then
                    y = y + 1
                Else
                    y = 1
                End If
            End If
        Next
        rsNew.Update
    Loop
    Close #1

and from there you have to put it into an table of your database
    PS I didn't debug this



Sun, 22 Sep 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Reading text file to create Access table

2. How To Read ASCII File And Put in to AS400 Or SQLServer Table

3. export data from an Access table to a text file via vbScript

4. Text file to Access table need direction

5. read a file and put the contents in a text box

6. File Association/reading text file data

7. ** File I/O ** Need help reading text file into String variable

8. MS Access--Putting one record into a text file

9. can't access data from text file use Data control

10. Reading a comma delimited text file and inserting the values into SQL Server table

11. Reading from a text file and writing toa text file from Vis Bas 6.0

12. Convert Access 7.0 table/data to text

 

 
Powered by phpBB® Forum Software