Solved

updating an access database table from a textfile

Posted on 1998-07-15
2
145 Views
Last Modified: 2010-05-03
i'm trying to write a function that will open a text file for reading, then read the file line by line and put it into an existing table- graph. i am trying first just to read the lines and past it into one of the table's fields without deviding it to fields.
i wrote:
Private Sub load_Click()
Dim dbss As Database
Set dbss = OpenDatabase("db3") 'db3 is my dbase name
Dim textline As String
Open "a:movefile.txt" For Input As #1
Do While Not EOF(1)
    Line Input #1, textline
    dbss.TableDefs("graph").Fields("num") = textline
    Loop
Close #1
End Sub
the thing is it doesn't work.
the textline format in the file is:
:spo2= (3 digits number) pr= (3 digits number) no probe
if you can please tell me also how to read the file so i can imidiatly past the 3 digits numbers in to diffrent fields in table graph i would give you a very high score.
thank you my saviour.
0
Comment
Question by:ilanm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
gissing earned 100 total points
ID: 1465773
I think I see what you are trying to do. The code looks roughly like this:


Private Sub foo()

Dim db As Database
Dim rs As Recordset
Dim h As Long
Dim s As String
Dim n1 As String
Dim n2 As String
Dim i As Integer

    Set db = OpenDatabase("db3")
   
    Set rs = db.OpenRecordset("graph", dbOpenTable)
   
    h = FreeFile
    Open "a:movefile.txt" For Input As #h
   
    Do While Not EOF(h)
   
        Line Input #h, s
       
        i = InStr(s, "spo2=")
        n1 = Mid$(s, i + 5, 3)
       
        i = InStr(s, "pr=")
        n2 = Mid$(s, i + 3, 3)
       
        rs.AddNew
        rs.Fields("num1").Value = n1
        rs.Fields("num2").Value = n2
        rs.Update
   
    Loop
   
    Close #h
   
    rs.Close
    Set rs = Nothing
   
    db.Close
    Set db = Nothing

End Sub


Obviously you will need to change the field names to suit. Also, some error handling and a transaction wouldn't go amiss.
0
 

Author Comment

by:ilanm
ID: 1465774
i don't know if it works but this is the first time someone actualy submits a code to his answer.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB6 Compile Compatibility Issue 4 130
how to Classify of email (pdf attachments) 7 57
backup program with robocopy 6 91
Collapse and expand table in Word 2010 2 159
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question