Hi. I have a web browser control on a form that, when the form is opened, I want to display the contents of a file folder. I can't. To identify the problem, I simplified my testing to just this: a form with a web browser control and a button.
The code I am try to run for my test (my actual business intent is more complex) is simply this line of code with nothing else in the procedure:
Me!WebBrowser3.Navigate "C:\Users\WAB\Documents\_My Access Apps\"
This single line of code --- with no other code before or after --- will not work in the form's OnOpen event: the browser displays an HTML page that says "The address is not valid." Surprisingly, when I right-click on the browser control
and select "Back", it then displays my file folder correctly --- even though I had closed and reopened the form just before running the test so there shouldn't be a previous page content it could go back to. Unfortunately, simply adding a GoBack
to my code is not a solution. That only causes an error when the form is next reopened.
More surprisingly, this same simple line of code does work perfectly in the OnClick event of a button on the form, again with no other code before or after it. In my test, I deleted my OnOpen event
code and closed and reopened the form before testing the code in the button, so the two tests were independent. I am baffled.
I've encountered this problem on two different computers today using Access 2013 (one at work and one at home, both test databases being created from scratch) and on another computer using Access 2010 (also at home and also from scratch). It makes no
difference what folder path I use. I've changed none of the default properties of the form or webbrowser control other than inserting code for the form's OnOpen event. I've spent two hours searching the web before posting and have not found anyone
who has had the same problem.
Thanks in advance for any help you can provide.