Results 1 to 3 of 3

Thread: Update MS access table with the data from file

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    263

    Question Update MS access table with the data from file

    Hi,

    Can anyone help me how to update an MS access table based on the date im reading from my file?

    I have table name "PROFILE" and I'm getting the update of it from HTML/TXT file.

    The table having 2 columns (NAME, SURNAME). I want to clear all the content of table "PROFILE" before the below codes run.

    Let say from HTML:

    <name>Asher</name>
    <visibility>1</visibility><open>0</open>
    <Folder id="1">
    <surname>David</surname>
    <visibility>1</visibility><open>0</open>
    <Placemark>



    Now here is my sample code:

    Code:
    Do While Not EOF(1)
        Line Input #1, InputData
        
        If Left(InputData, 6) = "<name>" Then
                     ' Update column "NAME" containing Mid(InputData,10,x)
        End If
    
        If Left(InputData, 9) = "<surname>" Then
                     ' Update column "SURNAME" containing Mid(InputData,10,x)
        End If
    
    Loop
    Close MyReadNum

    ANy help? How can I also determin fast the value of x to put in my MID statement? Im doing it in VBA ms access
    Last edited by Asher David; Oct 13th, 2008 at 06:03 AM.
    "Its easy to teach FAITHFUL MAN to be ABLE than ABLE MAN to be FAITHFUL"

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Update MS access table with the data from file

    Quote Originally Posted by Asher David
    The table having 2 columns (NAME, SURNAME). I want to clear all the content of table "PROFILE" before the below codes run.
    Then I would run an SQL DELETE query...that will remove all records from your table with just one statement.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    263

    Question Re: Update MS access table with the data from file

    Can you give me some sample syntax?

    But then how to update table in MS access also?

    Should I used like ADO connection something like below?

    Code:
    Public goCnn As ADODB.Connection
    Public oRs As New ADODB.Recordset
    
    oRs.AddNew
    On Error Resume Next
          
          If Left(InputData, 6) = "<name>" Then
                 oRs.AddNew  
                 oRs("name") = Mid(InputData,10,x)
          End If
    
          If Left(InputData, 9) = "<surname>" Then
                  oRs.AddNew
                 oRs("surname") =  Mid(InputData,10,x)
          End If
    
    
    
    Loop
    Close #1  
    
    oRs.Close
    goCnn.Close
    How to determine the value of x inside my condition:

    Code:
    If Left(InputData, 6) = "<name>" Then
                 oRs.AddNew  
                 oRs("name") = Mid(InputData,10,x)

    So that I can get the exact value of surname and name?
    "Its easy to teach FAITHFUL MAN to be ABLE than ABLE MAN to be FAITHFUL"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width