Solved

PDF not working in Axccess 2003 after creating a new report

Posted on 2009-03-29
11
319 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
 

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now