Solved

PDF not working in Axccess 2003 after creating a new report

Posted on 2009-03-29
11
320 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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.

867 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

16 Experts available now in Live!

Get 1:1 Help Now