Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    steve4864 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    10

    Show PDf in form causes 2 copies to be printed

    Having a problem with showing a PDF file in a form. I have a text box that is filled from a browse dialog button and the selected file should show in a web browser control, as shown in instructions here, but when I do it, whenever I click the browse button, 2 copies of the form are sent to the printer. I just can't work it out. Seems that whenever text is entered into the path text box, it tries to print. Completely mystified noob.

  2. #2
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    2 copies of the form are sent to the printer
    Your post is kinda confusing because you say it's trying to print when you enter text in the textbox, plus when it does print, it prints 2 copies? How does that fit in with the video instructions? You'll have to provide your code and more info.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    steve4864 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    10
    Sorry, I'm confused myself. I think? it's printing 2 copies because when I browse to a file and select it, the text in the "Path" text box changes and it prints and also the web browser control changes and it prints too? Maybe?

    Here is the code for the browse button

    Code:
    Option Compare Database
    Option Explicit
    
    
    Private Sub Command7_Click()
    
    
    Dim file As FileDialog
    Set file = Application.FileDialog(msoFileDialogFilePicker)
    
    
    file.AllowMultiSelect = False
    
    
    If file.Show Then
    Me.Path = file.SelectedItems.Item(1)
    End If
    
    
    End Sub
    The web browser control control source is set to [Path]

    This is faithful to the video instructions as far as I know.

    Thanks

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Tested code. Works perfectly. Cannot replicate issue.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Please use code tags for anything more than a few lines, for easier reading and indentation.
    This is faithful to the video instructions as far as I know
    Except the video said nothing about printing anything. The problem must be in that section. What you've just posted only puts the path in the text box.
    Path is a reserved word and shouldn't be used for an object name.

    EDIT: as an afterthought, so is FILE
    Last edited by Micron; 12-23-2017 at 04:12 PM. Reason: added info

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Yes, path goes in textbox and WebBrowser control source references the textbox. It works.

    To provide db for direct analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    I think the method is
    Me.Browser9.Object.Navigate "https://www.accessforums.net/showthread.php?t=69710"

  8. #8
    steve4864 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    10
    Hi June7

    Yes, everything works apart from it wanting to print all the time. Maybe a problem in the browse button code? Instructions said I may get prompted for a reference when entering the code but I wasn't. Video showed "Microsoft Office 15 Object Library"

    Click image for larger version. 

Name:	Reference.jpg 
Views:	10 
Size:	64.1 KB 
ID:	31773

    which is not on my system?

    Have attached db(I think, it's all new to me).
    Attached Files Attached Files

  9. #9
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Seems your attachment uses some kind of feature that's not backwards compatible with 2007.
    Sorry, can't help under those circumstances.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Downloaded your file. I am using Access2010. I get error "User-defined type not defined" on the FileDialog object. Had to add the Microsoft Office 14 Object Library. Then run your code. WebBrowser displays PDF and no attempt to print. No idea what it is about your system. Suggest you try a different computer.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    steve4864 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    10
    Quote Originally Posted by June7 View Post
    Downloaded your file. I am using Access2010. I get error "User-defined type not defined" on the FileDialog object. Had to add the Microsoft Office 14 Object Library. Then run your code. WebBrowser displays PDF and no attempt to print. No idea what it is about your system. Suggest you try a different computer.
    OK. On a different PC now.
    Different problem.
    How do I get that reference applied. Option is unavailable when I edit it in code window. Does it depend on what's selected?
    How do you add the Office 14 Object Library?

    Steep learning curve for me today. Appreciate your help. Cheers.

  12. #12
    steve4864 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    10
    Same problem on different PC. Must be that Microsoft Office 14 Object Library that I need.

  13. #13
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Code can't be running (not sure, based on your comments). You may not be using that version of Office. Pick the latest version you find in the references list.
    The error means that no type library is referenced that would tell Access what the file dialog object is all about. That object goes so far back that I can't recall what version it started with, but you're now seeing the effects of distributing an application across multiple users who may be using different versions. Where I worked, they didn't dump older dll's,tlbs, etc. Rather, they left them there so that many user db's across the company would continue to run for the most part.

    14.0 was for 2010

  14. #14
    steve4864 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    10
    Thanks for trying to help me. As a workaround I'll convert PDF's to JPEG and no reference to Office Library in VBA code. It works and no printing!!

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Select library reference from VBA menu: Tools > References > find in list and check it.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 09-08-2016, 12:43 PM
  2. Converting from a pre-printed form
    By crowegreg in forum Reports
    Replies: 3
    Last Post: 07-02-2014, 08:23 AM
  3. Replies: 2
    Last Post: 06-20-2012, 02:21 AM
  4. Replies: 3
    Last Post: 06-11-2012, 08:27 PM
  5. Replies: 5
    Last Post: 11-03-2011, 08:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums