View pdf files within the form in MS Access 2013 Not working with Adobe Reader (1 Viewer)

Alhakeem1977

Registered User.
Local time
Today, 08:40
Joined
Jun 24, 2017
Messages
308
Hi All,
I have got a Microsoft Access db to view pdf files within the form but it does not succeed is there another suggestion to do so?

I tried to upload my db in this thread it's allowed, below is my code:
Code:
Private Sub btnBrowse_Click()
Dim file As FileDialog
Set file = Application.FileDialog(msoFileDialogFilePicker)

file.AllowMultiSelect = False

If file.Show Then
  Me.txtFileLocation = file.SelectedItems.Item(1)
End If

End Sub
 

Micron

AWF VIP
Local time
Today, 01:40
Joined
Oct 20, 2018
Messages
3,475
What are you trying to display/view these pdf files in the form (what type of control)? The code you posted allows you to pick a file, then it makes txtFileLocation on the form equal the name of the selected item. Beyond that, it does nothing.
 

Alhakeem1977

Registered User.
Local time
Today, 08:40
Joined
Jun 24, 2017
Messages
308
Thanks for your prompt response.
It's a Web Browser Control window within the form I set it control Source as [txtFileLocation].

I can easily view any image but I can view pdf or word document it's open in it's own software.

I would prefer to allow me editing the document within the form if it's possible.

Thanks
 

vba_php

Forum Troll
Local time
Today, 00:40
Joined
Oct 6, 2019
Messages
2,884
I actually did say goodbye and promised I wouldn't post anything more around here regarding technical answers, but alas I saw this and thought there was something to say. Alhakeem, are you saying that the code you posted actually *works*? and you can see the PDF document in your browser control? I was under the impression that your code:
SQL:
Me.txtFileLocation = file.SelectedItems.Item(1)
should have been written like this in order for it to work:
SQL:
Me.txtFileLocation = file.SelectedItems(1)
If that is true, and someone were to address this problem of yours:
I would prefer to allow me editing the document within the form if it's possible.
it is very possible that they would say it's not possible. Editing a PDF with a PDF-specific viewing piece of software like Adobe Acrobat is even a challenge. When you view a PDF through an Access control, I seriously doubt Access or any of it's internal resources have any ability to do what Adobe Acrobat can do. So I would guess the answer to your question would be: NO, you can't edit the PDF in a web browser control. as a test, see the following image, which shows how it is not possible to edit a PDF in an *actual* web browser like firefox (at least not that I know of):

 

Attachments

  • viewing_pdf_in_a_browser.jpg
    viewing_pdf_in_a_browser.jpg
    241.8 KB · Views: 440
Last edited:

Micron

AWF VIP
Local time
Today, 01:40
Joined
Oct 20, 2018
Messages
3,475
I have got a Microsoft Access db to view pdf files within the form but it does not succeed
I should have asked you what the bold text part meant. Now I think you're saying it shows the correct document but you can't edit it. What looks different from code that I use is that I'd write file.SelectedItems.(1) not file.SelectedItems.Item(1). I would also refresh the form as in Me.Refresh or Me.Recalc (not Me.Requery).

I'm not a big user of these control types so I'm uncertain if you should be using an unbound object control rather than a web browser. Try the code change suggested above and if that doesn't help, then you should post what the textbox contains as a value when that code runs.

Regardless, you cannot edit the file in the form as far as I know. You can launch the application that created it and edit it there.
 

Alhakeem1977

Registered User.
Local time
Today, 08:40
Joined
Jun 24, 2017
Messages
308
I actually did say goodbye and promised I wouldn't post anything more around here regarding technical answers, but alas I saw this and thought there was something to say. Alhakeem, are you saying that the code you posted actually *works*? and you can see the PDF document in your browser control? I was under the impression that your code:
SQL:
Me.txtFileLocation = file.SelectedItems.Item(1)
should have been written like this in order for it to work:
SQL:
Me.txtFileLocation = file.SelectedItems(1)
If that is true, and someone were to address this problem of yours:it is very possible that they would say it's not possible. Editing a PDF with a PDF-specific viewing piece of software like Adobe Acrobat is even a challenge. When you view a PDF through an Access control, I seriously doubt Access or any of it's internal resources have any ability to do what Adobe Acrobat can do. So I would guess the answer to your question would be: NO, you can't edit the PDF in a web browser control. as a test, see the following image, which shows how it is not possible to edit a PDF in an *actual* web browser like firefox (at least not that I know of):


Thank you so much for your replay, you helped me a lot for my previous application, I would strongly continue helping people like me for their technical issues.

Actually my problem is that the code works fine displaying the pdf, Word and jpg files within the browser control as expected in MS Access 2010, but our organization has upgraded our MS Office to 2013 with some of our users with Adobe Reader and some other with Adobe Acrobat like me, unfortunately the Browser displaying only jpg within the form but when I browse to a pdf or MS Word document it opens separately outside the Browser control.

Thanks for your continues support.
 

vba_php

Forum Troll
Local time
Today, 00:40
Joined
Oct 6, 2019
Messages
2,884
unfortunately the Browser displaying only jpg within the form but when I browse to a pdf or MS Word document it opens separately outside the Browser control.
you are putting the *path* of the file in the textbox, Alhakeem. so you are saying that you are actually clicking on that path (it's a hyperlink, right?) and it's opening with the default program for the file extension at the end of the path? for instance, MS word documents are opening with MS word? and PDF's are opening with Adobe's program? That makes perfect sense. I would highly doubt you could change the association of a file extension like ".docx" with a control object inside of MS Access because those associations are part of the windows operating system, set in the control panel, and file extensions are a way of telling a computer what program to use to open them with. The issue stems all the way back to the point in time when software engineers created software programs. Different file extensions exist for this very reason. But anyway, sorry for the long-winded lecture. Bottom line => I don't think you can do this. You may also want to consider talking to other people here about this, because I'm not trained in software engineering. I'm technically a businessman.
 

Alhakeem1977

Registered User.
Local time
Today, 08:40
Joined
Jun 24, 2017
Messages
308
Dear vba_php and Micron,

I change the code as both of you suggested,unfortunately, it still the same not showing the file within the form as below:


Capture.PNG


Code:
Private Sub btnBrowse_Click()
Dim file As FileDialog
Set file = Application.FileDialog(msoFileDialogFilePicker)

file.AllowMultiSelect = False

If file.Show Then
  'Me.txtFileLocation = file.SelectedItems.Item(1)
  Me.txtFileLocation = file.SelectedItems(1)
  'Me.Recalc
  Me.Refresh
End If
End Sub


Dear Micron,
I should have asked you what the bold text part meant. Now I think you're saying it shows the correct document but you can't edit it. What looks different from code that I use is that I'd write file.SelectedItems.(1) not file.SelectedItems.Item(1). I would also refresh the form as in Me.Refresh or Me.Recalc (not Me.Requery).

It showing the correct document but outside the Browser Control.
Please read my previous replay to vba_php #6 illustrates my problem.
 

Alhakeem1977

Registered User.
Local time
Today, 08:40
Joined
Jun 24, 2017
Messages
308
you are putting the *path* of the file in the textbox, Alhakeem. so you are saying that you are actually clicking on that path (it's a hyperlink, right?) and it's opening with the default program for the file extension at the end of the path? for instance, MS word documents are opening with MS word? and PDF's are opening with Adobe's program? That makes perfect sense. I would highly doubt you could change the association of a file extension like ".docx" with a control object inside of MS Access because those associations are part of the windows operating system, set in the control panel, and file extensions are a way of telling a computer what program to use to open them with. The issue stems all the way back to the point in time when software engineers created software programs. Different file extensions exist for this very reason. But anyway, sorry for the long-winded lecture. Bottom line => I don't think you can do this. You may also want to consider talking to other people here about this, because I'm not trained in software engineering. I'm technically a businessman.
Thanks a lot for your help, I am waiting for any other solution.
you are always on time.

Thanks again!
 

vba_php

Forum Troll
Local time
Today, 00:40
Joined
Oct 6, 2019
Messages
2,884
Thanks a lot for your help, I am waiting for any other solution.
I've already told you everything I can, my man. I see that you're communicating with thDBguy on the other access forum? He knows pretty much everything there is to know about Microsoft Access. Have you contacted him and see what he has? I'm telling you though, this is pretty much impossible IMO. But if you're interested, in my 10 year career doing this stuff, I've created countless workarounds for people that attempt the impossible and end up pulling their hair out because they're being completely unrealistic, and they are usually very happy with what I tell them and give to them as a solution to settle on. But if you're insistent on doing things this way, I wish you luck! :)
 

Micron

AWF VIP
Local time
Today, 01:40
Joined
Oct 20, 2018
Messages
3,475
As I mentioned, I think you are using the wrong control for this. If I specify a pdf (and I do not have Adobe Acrobat) I can only see the file in the form. If I specify a Word document (I have Word app) it wants to save or open the file. It seems to depend on whether or not you have the native app for the file in question. I suggest you try an unbound object control or perhaps an ActiveX web browser, but I'm afraid this is unfamiliar territory for me so I should bow out. Sorry I wasn't more help.
 

Alhakeem1977

Registered User.
Local time
Today, 08:40
Joined
Jun 24, 2017
Messages
308
I've already told you everything I can, my man. I see that you're communicating with thDBguy on the other access forum? He knows pretty much everything there is to know about Microsoft Access. Have you contacted him and see what he has? I'm telling you though, this is pretty much impossible IMO. But if you're interested, in my 10 year career doing this stuff, I've created countless workarounds for people that attempt the impossible and end up pulling their hair out because they're being completely unrealistic, and they are usually very happy with what I tell them and give to them as a solution to settle on. But if you're insistent on doing things this way, I wish you luck! :)
Thank you very much.
 

Users who are viewing this thread

Top Bottom