开发者

MSAccess VBA code not working on second run

The below code is bound to a button. For some reason the below code executes correctly the first time. On the second time, for some users, it does not populate the fields on the website. What could the issue be?

Me!WebBrowser0.Navigate "http://bk00app0001/PMD Image Upload/"

While Me.WebBrowser0.Busy
    DoEvents
Wend

Me!WebBrowser0.Document.getElementById("MainContent_Year").Value = Forms![Main Menu]![SeasonList].Value
Me!WebBrowser0.Document.getElementById("MainContent_ItemNumber").Value = Me.OpenArgs
Me!WebBrowser0.Document.getElementById("MainContent_btnLock").Click

I believe I need to set Me!WebBrowser0 = Nothing on the Close event. However, Me!WebBrowser0 = Nothing throws an error. Any ideas as to how to do this?

UPDATE

On the second time this code is called MS Access throws the following error when it hits this line:

Me!WebBrowser0.Document.getElementById("MainContent_Year").Value = Forms![Main Menu]![SeasonList].Value

'Object variable or With block variable not set'  

Looks like it was a timing issue. I was able to solve it by addi开发者_如何学Cng the following code before I set any of the values on the webpage:

While Me!WebBrowser0.Document.getElementsByTagName("p").Length < 10
     DoEvents
Wend

I am now getting the error: "Runtime error '430' class does not support Automation or does not support expected interface"

This error refers to the following line of code:

Set Cnxn = New ADODB.Connection

Here is a screenshot for the line of code above: http://postimage.org/image/2v7p8diis/

The above code is called when I close the form that has the button that calls the browser code.


While Me!WebBrowser0.Document.getElementsByTagName("p").Length < 10
 DoEvents
Wend

Solved the first issue.

The second issue was due to referencing a non-existent DLL on the user's machine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜