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
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.
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?