Solved

PDF not working in Axccess 2003 after creating a new report

Posted on 2009-03-29
11
324 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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

756 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