如何解决从网页检索数据后,MS Access 不会使用新值更新表
我设计了一个表格来从我的公司网页中提取日期,我可以更改日期,然后它会更新我公司页面中的日期。这就像一个魅力。 如果我按下按钮来检索相同的信息,则显示的日期将是旧日期,而不是新日期。我检查了网页,日期已经到位。如果我关闭 Access 并重新打开它,并验证日期,则它只会显示我所做的更改。
我错过了什么?
Sub tbl50_UpdateModemDates() 'Retrieve the modem listed in the table and update the Delivery date,keeps the difference days between Preconfig,Loadout and Deliver dates
Dim HTMLDoc As New MSHTML.HTMLDocument
Dim HTMLBody As MSHTML.HTMLBody
Dim URL As String
Set HTMLDoc = New MSHTML.HTMLDocument
Set HTMLBody = HTMLDoc.body
Dim ModemStatus As String
Dim MyRTBL50 As Recordset
Const GETModemURL = "http://tanwebs.corp.halliburton.com/pls/log_web/mobssus_vieword$order_mc.QueryViewByKey?P_SSORD_ID="
Set MyRTBL50 = CurrentDb.OpenRecordset("tbl50_UpdateModemDateAutomatically",dbOpenDynaset)
'Empty the table,keep the modem number only
btnEmptyTable_Click
While MyRTBL50.EOF = False
ModemNr = MyRTBL50![ModemNr]
URL = GETModemURL + ModemNr
HTMLDoc.body.innerHTML = RetrieveModemViagetmethod(URL)
ModemStatus = HTMLBody.getElementsByTagName("table")(0).getElementsByTagName("tr")(19).getElementsByTagName("td")(1).innerText
MyRTBL50.Edit
If ModemStatus = "Activated" Or ModemStatus = "Not Activated" Or ModemStatus = "Ready" Then 'Retrive the data for each colum
'Set maintable = HTMLBody.getElementsByTagName("table").Item(0)
'Set trcollection = maintable.getElementsByTagName("TR")
Set trcollection = HTMLBody.getElementsByTagName("table").Item(0).getElementsByTagName("TR")
For Each tditem In trcollection
Select Case tditem.getElementsByTagName("TD")(0).innerText
Case "Sales Order:"
'ZSPO
MyRTBL50![ZSPO] = tditem.firstChild.nextSibling.innerText
Case "Rig Name:"
'RigName
MyRTBL50![Rig] = tditem.firstChild.nextSibling.innerText
Case "Well Number:"
'WellName
MyRTBL50![Well] = tditem.firstChild.nextSibling.innerText
Case "Well Section:"
'Section Size
MyRTBL50![Section] = tditem.firstChild.nextSibling.innerText
Case "Pre Config Date:"
'Preconfig
'MyRTBL50![PreConfigDate] = tditem.getElementsByTagName("TD")(1).firstChild.Value
MyRTBL50![PreConfigDate] = HTMLDoc.getElementById("P_DATE_LOAD").Value
a = HTMLDoc.getElementById("P_DATE_LOAD").Value
Case "Loadout Date:"
'Loadoutdate
MyRTBL50![LoadOutDate] = tditem.firstChild.nextSibling.innerText
Case "Deliver To Customer:"
MyRTBL50![DeliveryDate] = tditem.firstChild.nextSibling.innerText
End Select
If ModemStatus = "Ready" Then
MyRTBL50![Comment] = "Modem Ready. Changes are not allowed."
End If
Next
Else
MyRTBL50![Comment] = "Skipped: modem already completed or canceled."
End If
MyRTBL50.Update
MyRTBL50.MoveNext
Refresh
Wend
MyRTBL50.Close
Set MyRTBL50 = nothing
Set HTMLDoc = nothing
Set HTMLBody = nothing
End Sub
以及表单的可视化。应该正确显示的值是中间的 3 个日期,在它们更新后,我单击按钮检索调制解调器日期。
谢谢! 塞尔吉奥
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。