Solved

PDF not working in Axccess 2003 after creating a new report

Posted on 2009-03-29
11
325 Views
Last Modified: 2012-05-06
I generated an Access 2003 DB with the help of several experts, and I thank everybody for all there help. I took the advise of the experts and created a report, which I want to make into a PDF. I received some code to put behind my PDF button on my form "contract", and it was working great with my test report "contracts". So far so good. Now I renamed my test report and used the wizard to make a new one, and I kept the name the same as the test report that worked. Now the PDF button prints the report to my laser printer instead of CutePDF, like it used to. I can't see anything I did to cause this, but I am sure I did. I figured keeping the report name the same as the test one that worked would avoid problems, but apparently I was wrong. I uploaded the DB so you can hopefully spot what I did wrong. The other thing I noticed is when I hover my cursor over the old test report it shows the printer as CutePDF, asnd when I hover the cursor over the new report it shows my laser printer.
thanks experts...Bob
Limo-Rental.mdb
Limo-Rental-be.mdb
0
Comment
Question by:bobrossi56
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 11

Expert Comment

by:mildurait
ID: 24015346
Prior to running the report you can set the application printer with vba.  Something like below may work for you.

Sub cmdPrint_Click()
 
       dim p as printer
       for each p in application.printers
             if p.name = "CutePDF" then
                  application.printer = p
                  exit for
             end if
       next

       'your code to open/print report

End Sub
0
 

Author Comment

by:bobrossi56
ID: 24015364
The code I got from one of the other experts specifically created a PDF of just the current form I had open. Will the above do that? I was hoping to continue to use the code I had and figure out why creating a new reoprt with the same name broke it.
0
 
LVL 11

Expert Comment

by:mildurait
ID: 24015373
All the above will do is the set the printer for your application.
Suggest you try running this prior to running the existing code.
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Comment

by:bobrossi56
ID: 24015381
OK, I did and it erros on "if p.name "
0
 
LVL 11

Expert Comment

by:mildurait
ID: 24015427
Try below & Let me know what comes up in the message box.
Get the default printer
    
    Set prtDefault = Application.Printer
    
    'assign CutePDF, make sure the name is correct in printer & faxes
    strDefault = "CutePDF Writer"
    'SetDefaultPrinter "CutePDF Writer"
    dim p as printer
    for each p in application.printers
        if p.DeviceName = strDefault then
           application.printer = p
           exit for
        end if
    next
    msgbox appliction.printer.DeviceName
   
   'Print the report
    stDocName = "contracts"  '                               Right below is the filter/criteria
    DoCmd.OpenReport stDocName, acNormal, , "PriKey = " & Forms![contract]![PriKey] & ""
         
   ' Reset the default printer
    Application.Printer = prtDefault

Open in new window

0
 
LVL 11

Expert Comment

by:mildurait
ID: 24015436
Sorry let me  try again.
    Set prtDefault = Application.Printer
    
    'assign CutePDF, make sure the name is correct in printer & faxes
    strDefault = "CutePDF Writer"
    'SetDefaultPrinter "CutePDF Writer"
    dim p as printer
    for each p in application.printers
        if p.DeviceName = strDefault then
           application.printer = p
           exit for
        end if
    next
    msgbox application.printer.DeviceName
   
   'Print the report
    stDocName = "contracts"  '                               Right below is the filter/criteria
    DoCmd.OpenReport stDocName, acNormal, , "PriKey = " & Forms![contract]![PriKey] & ""
         
   ' Reset the default printer
    Application.Printer = prtDefault
 

Open in new window

0
 

Author Comment

by:bobrossi56
ID: 24015466
OK, when I click the PDF button I get  a message box that says "CutePDF Writer", and when I click OK, it prints the report to my laser printer.
0
 
LVL 11

Accepted Solution

by:
mildurait earned 500 total points
ID: 24015521
OK.
The issue is not with the code, it is with page setup.

a) Open up your report in design view.
b) From the file menu choose page setup.
c) On the page tab choose default as the printer for contacts.
0
 

Author Comment

by:bobrossi56
ID: 24015555
Your a genius....that was it. I knew it had to be something about the new report vs. the test report because the code I had worked before. I didn't know, being a novice as I am, that this option was available in a report to pick a specific printer. Thanks so much for sticking with me. Much appreciated.
-Bob
0
 

Author Closing Comment

by:bobrossi56
ID: 31564140
Great help and problem solved...thx agaiin
0
 
LVL 11

Expert Comment

by:mildurait
ID: 24015561
No problems..
Not genius yet (guru)...
You have to answer lots of questions here before you become a genius LOL
0

Featured Post

RoboForm Secure Password Management System

RoboForm Everywhere - Superb Browser Support
Windows / Apple / IOS / Android / Linux / Chrome OS
Use different complex passwords everywhere
Best Secure Password Management by far
Synchronize all of your devices instantly
Safe, Secure & Highly Recommended!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question