How to avoid error (0:521) of Adobe Acrobat Reader showing PDF files in a Form with Web Browser Control (1 Viewer)

lauro

Member
Local time
Yesterday, 16:00
Joined
May 18, 2012
Messages
59
Hi,

In Access I have a table to store PDF file. Not the actual file but only their Full Names.
I decided to use the Web Browser Control to display the content of the PDF files. The Source Control of the Web Browser Control is linked to the Full Name text box.

Everything works almost fine, but changing record I often receive an error from Adobe PDF viewer: A problem occurrred in Adobe Acrobat/Reader. If in execution, exit and try again. (0:521).

I never used the Web Browser Control before so I don't know how to solve it.
I tried to insert in the on Current event a delay and a requery of the Web Browser Control: it's better, but sometimes I still get the same error.

Thanks for any help, Lauro
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:00
Joined
May 7, 2009
Messages
19,245
which version of Access do you use?
if you are only using the webbrowser for pdfs only, you can use Adobe PDF Reader control
directly to your form.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 18:00
Joined
Feb 28, 2001
Messages
27,189
I prefer arnelgp's suggestion. However, ... Another method I might try would be to not automatically link the source control, but rather have an event routine load the .ControlSource in, say, the OnCurrent event. Then when you are about to navigate, trigger an erase of the .ControlSource of that control. Since a .PDF is not a true web page, you are making use of a control not specifically designed for those contents. It is a coincidence that most web browsers understand .PDF well enough to display them.
 

lauro

Member
Local time
Yesterday, 16:00
Joined
May 18, 2012
Messages
59
which version of Access do you use?
if you are only using the webbrowser for pdfs only, you can use Adobe PDF Reader control
directly to your form.
I'm using Microsoft 365, but I would like my code to run also on Access 2010.
The Adobe PDF Reader Control is a control developed by Adobe? Can I insert it directly in an Access Form? Can I do it by VBA?
Thanks a lot, Lauro
 

lauro

Member
Local time
Yesterday, 16:00
Joined
May 18, 2012
Messages
59
I prefer arnelgp's suggestion. However, ... Another method I might try would be to not automatically link the source control, but rather have an event routine load the .ControlSource in, say, the OnCurrent event. Then when you are about to navigate, trigger an erase of the .ControlSource of that control. Since a .PDF is not a true web page, you are making use of a control not specifically designed for those contents. It is a coincidence that most web browsers understand .PDF well enough to display them.
Thank you for you answer.
I disconnected the Web Browser Control from the TextBox. I used On Current event to assign the ControlSource of the Web Browser Control.
I was not able:
  • to find the event immediatly before On Current when the user navigate through records
  • How to erase the Control Source of the WBC even in the same On Current Procedure, before the new assignement.
Your solution is 95 % fine. Sometime still the error appears.
Thanks again, Laro
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 18:00
Joined
Feb 28, 2001
Messages
27,189
Thank you for you answer.
I disconnected the Web Browser Control from the TextBox. I used On Current event to assign the ControlSource of the Web Browser Control.
I was not able:
  • to find the event immediatly before On Current when the user navigate through records
  • How to erase the Control Source of the WBC even in the same On Current Procedure, before the new assignement.
Your solution is 95 % fine. Sometime still the error appears.
Thanks again, Laro

The problem with navigating with a non-dirty form is that you usually get no particular event before a navigate. A dirty form would cause a Before Update and After Update event, but that isn't a good idea in the long run. Perhaps you can turn off warnings (DoCmd.SetWarnings = FALSE) then change the control source then turn warnings on again (DoCmd.SetWarnings = TRUE ). If you do that, you might be able to quiet it down. In general, if you don't know whether you will get a warning message, you want to leave warnings enabled as a debugging tool. There is almost no time during development that warnings should be disabled. For something in production mode, that is a harder decision, since if you debugged it well, you won't get errors anyway.

As to the other post, I have not played with Adobe libraries very much, but the idea is that if you have an Adobe control to view an Adobe product, they should behave well together.
 

Users who are viewing this thread

Top Bottom