WebBrowser Field update (1 Viewer)

Craig6

Registered User.
Local time
Today, 04:26
Joined
Jun 20, 2019
Messages
33
Hello, I have inserted a field on my form using the 'web Browser Control' tool. In there I have linked it to a file path on my server. The idea is that when I select a record this field displays the folders that are in that file path. This allows me to get quick access to those folders and the files within them. This works well and am generally happy with it. However, when I create a new record this field is naturally empty until I set the path in another field. After I have done this, the only way for this 'Web Browser Control' field to display the contents is if I close the record and reopen it. I have tried alsorts including ReCalc, Refresh, Repaint, Requery all to no avail. If anyone has any ideas for me I would be very grateful. Thanks in advance.
 

Attachments

  • Screenshot 2021-07-20 172616.jpg
    Screenshot 2021-07-20 172616.jpg
    35.8 KB · Views: 29

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:26
Joined
Oct 29, 2018
Messages
16,216
Just a guess, but maybe try Navigate? As in:
Code:
Me.BrowserControlName.Navigate NewFilePathHere
Hope that helps...
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:26
Joined
May 7, 2009
Messages
13,784
add code to the AfterUpdate event of your "path" textbox:

private textboxName_AfterUpdate()
If Len(Dir$([textboxName])) <> 0 Then
Me.WebBrowse0.Navigate [textboxName]
End If
end sub
 

Craig6

Registered User.
Local time
Today, 04:26
Joined
Jun 20, 2019
Messages
33
Thank you for your replies. I tried both (which are very similar if not the same) and I get a compile error: method or data member not found with the .Navigate section highlighted.
 

Attachments

  • Screenshot 2021-07-21 083229.jpg
    Screenshot 2021-07-21 083229.jpg
    26.4 KB · Views: 34

Craig6

Registered User.
Local time
Today, 04:26
Joined
Jun 20, 2019
Messages
33
Just to add: Can you also tell me why is it that when I close the form and then open it again it works perfectly? What happens in that process that I can't replicate whilst staying in the form?

The picture below shows my Control Source for the WebBrowser. As these fields aren't populated when I create a new record the browser is blank. Once I've completed the record these fields are populated. For example, the cboSupportType.Column4 has the file path link in. So I've also tried your code on this too and get the same compile error above. Again thanks for looking at this for me.
 

Attachments

  • Screenshot 2021-07-21 084419.jpg
    Screenshot 2021-07-21 084419.jpg
    41.2 KB · Views: 36

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:26
Joined
May 7, 2009
Messages
13,784
which webbrowser are you using? the modern one or the legacy?
if modern, can you try on the afterupdate again of the textbox:

Me.Webbrowser282.ControlSource = "=""" & [Text285] & """"
 

Craig6

Registered User.
Local time
Today, 04:26
Joined
Jun 20, 2019
Messages
33
I'm not sure what it's called but I got it from the standard design toolbar in Access 2016 as shown in the picture below.
I tried what you suggested and it worked. Thank you! However, it's created another problem that I thought I had overcome before. So, when this text box is updated the WebBrowser displays my folders in that same directory - good, but when I click on a folder (i.e. go forward) I use my back button (Me.WebBrowser282.Object.GoBack) to go back and nothing happens?? It stays in that folder. It's all very strange. It's as if there is no history of where I just came from.
 

Attachments

  • Screenshot 2021-07-21 115233.jpg
    Screenshot 2021-07-21 115233.jpg
    43 KB · Views: 32
  • Screenshot 2021-07-21 115131.jpg
    Screenshot 2021-07-21 115131.jpg
    23.5 KB · Views: 11

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:26
Joined
May 7, 2009
Messages
13,784
ok, remove the last code i gave and use Navigate again
this time using:

Me.WebBrowser282.Object.Navigate Me.text285
 

Craig6

Registered User.
Local time
Today, 04:26
Joined
Jun 20, 2019
Messages
33
That worked just the same as the other code. So still no ability to go back to the folder I just left.
 

Craig6

Registered User.
Local time
Today, 04:26
Joined
Jun 20, 2019
Messages
33
Just an update; I am now using your code above (thank you) but I have had to put it in a command button because for the life of me I cannot get it to execute on anything else other than by clicking the webbrowser field (onclick) or a cmd button. So, this is the best I can get it so thanks for your help.
 

vhung

Member
Local time
Yesterday, 20:26
Joined
Jul 8, 2020
Messages
231
However, when I create a new record this field is naturally empty until I set the path in another field. After I have done this, the only way for this 'Web Browser Control' field to display the contents is if I close the record and reopen it. I have tried alsorts including ReCalc, Refresh, Repaint, Requery all to no avail. If anyone has any ideas for me I would be very grateful. Thanks in advance.

Your folder view is on large icon;
maybe try it also on details view, for easy folder control (on click and code path use)
 

Attachments

  • webfile.png
    webfile.png
    216.4 KB · Views: 32

Craig6

Registered User.
Local time
Today, 04:26
Joined
Jun 20, 2019
Messages
33
If I select the webbrowser control field and select View, I can change the view from large icon to details but when I go back a folder this resets. I cannot see anyway for this to default to details view.
 

Craig6

Registered User.
Local time
Today, 04:26
Joined
Jun 20, 2019
Messages
33
Just an update; I am now using your code above (thank you) but I have had to put it in a command button because for the life of me I cannot get it to execute on anything else other than by clicking the webbrowser field (onclick) or a cmd button. So, this is the best I can get it so thanks for your help.
I put the code (Me.WebBrowser282.Object.Navigate Me.text285) on a form timer along with a cancel code after 2 seconds so it now displays the contents when it's loaded and they stay visible. A bit Heath Robinson but it works!
 

vhung

Member
Local time
Yesterday, 20:26
Joined
Jul 8, 2020
Messages
231
If I select the webbrowser control field and select View, I can change the view from large icon to details but when I go back a folder this resets. I cannot see anyway for this to default to details view.
Good day
Try to open your folder on specific location (Example, folder on d:drive then click D: then on Drive Tools select details view)
 

Users who are viewing this thread

Top Bottom