Asked by:
adding data to a linked file through access

Question
-
Is it possible to add/amend records through access to a linked file. I am trying this with an html file, but it only seems to work one way. I can only add the records through the html file.
This is not for anything specific, I am just trying playing around with access and testing its limitations and functionality.
Tuesday, July 11, 2017 3:30 PM
All replies
-
Hi,
I've never tried linking a HTML file with Access but maybe linking to a Text file, like a HTML file only produces a "read-only" copy of the data. I know this is the case with linked Excel spreadsheets.
If so, the only way to update the HTML file from Access would be to use code to manipulate the file itself.
Just my 2 cents...
- Proposed as answer by Edward8520Microsoft contingent staff Thursday, July 27, 2017 8:10 AM
Tuesday, July 11, 2017 3:32 PM -
No, some of the drivers such as Text and HTML, are not true DBMS so the drivers that are provided have read-only capability. Other linked files, such as those you can connect through using a fully compliant ODBC driver, would be more likely to have update capability.
Paul ~~~~ Microsoft MVP (Visual Basic)
- Proposed as answer by Edward8520Microsoft contingent staff Thursday, July 27, 2017 8:10 AM
Tuesday, July 11, 2017 4:15 PM -
Hello,
As theDBguy suggested, the only way to update would be updated the HTML itself, so you could create macros to update the HTML file.
The following code could insert a new record in the first row of the html table.
It retrieves date dbo_tblUser.html using Microsoft HTML Object Library and use FileSystemObject to save as a new file. You could also use FileSystemObject to manipulate it as a text file.
Sub test() Dim doc1 As New HTMLDocument, doc2 As New HTMLDocument Dim ele As HTMLTable url = "file://E:\test\dbo_tblUser.html" Set doc1 = doc2.createDocumentFromUrl(url, "null") Do Until doc1.ReadyState = "complete" DoEvents Loop Set ele = doc1.all.tags("TABLE")(0) Dim row As HTMLTableRow Dim cell1 As HTMLTableCell, cell2 As HTMLTableCell Set row = ele.insertRow(1) Set cell1 = row.insertCell(0) Set cell2 = row.insertCell(1) cell1.innerText = "0" cell2.innerText = "TEST" Dim newHTML As String newHTML = doc1.head.innerHTML + doc1.body.innerHTML Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") Dim oFile As Object Set oFile = fso.CreateTextFile("E:\test\newHtml.html") oFile.WriteLine newHTML oFile.Close Set fso = Nothing Set oFile = Nothing End Sub
In addition, I found you have posted multiple threads, I am not sure whether previous issues have been resolved. I would suggest you recheck the previous threads, if they are resolved, I would suggest you mark the helpful reply as answer. If not, please feel free to keep following, we will try our best to help you.
Regards,
Celeste
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Edited by Edward8520Microsoft contingent staff Friday, July 14, 2017 8:29 AM add addition
- Proposed as answer by Edward8520Microsoft contingent staff Thursday, July 27, 2017 8:10 AM
Friday, July 14, 2017 7:52 AM