473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Report to PDF - Leban's PDF Tool. - Need to pass parameters

Hi all,

I am using Stephen Leban's Report To PDF tool since many months on my
Ms Access 2003 application.

I am happy to use it because it is really a very good tool.

BUT now I need some help, I have a report say rptEmployees that has recordsource as "Select * from employees..."

I need this report to be opened from several forms so I want to avoid using "where clause" in its recordsource.

Instead I use something like...
Docmd.OpenReport "rptEmployees","","EmployeeID=" & Me.EmployeeID

SO the big question is how can I create a PDF for an specific Employee,
whose EmployeeID=120 or any other value based on the form that opens rptEmployees.

Any help is highly appreciated.

Loving and Learning Ms-Access.
Ozair.
Sep 11 '08 #1
9 4293
NeoPa
32,556 Expert Mod 16PB
I'm not familiar with the PDF Tool. Does it not run from the already-opened report?

This sounds like it's specific to the tool interface itself, but we'll help if we can.
Sep 11 '08 #2
NeoPa,

Thanks for the reply, it can be used from a click of a command button.


Stephen Leban has been so caring that he published the MDB
that can be obtained from 'http://lebans.com/reporttopdf.htm'

In fact I am expecting that some expert can help me customize Stephen's code to meet my requirement.


Regards,

Ozair - Loving & Learning Ms-Access
Sep 12 '08 #3
puppydogbuddy
1,923 Expert 1GB
Hi,
For the record Leban's ReportToPDF is a user defined function (UDF) designed to convert Access Reports and Snapshot files to PDF documents without requiring an installed PDF Printer driver (e.g. Adobe).

http://www.lebans.com/reporttopdf.htm

If I understand your question correctly, you are already getting an unfiltered version of your Access report in PDF format, but do not know how to get a filtered version. For you, the answer is simple. The key trick is to call the Leban's function while the filtered Access report is the active object as shown below:
1.Create a global variable in Access for the report name >> Public gRptName As String. Make sure the variable name used here is the same variable name used in the Leban's function.

2. in your code, open the Access report in preview mode:
gRptName = "rptEmployees"
Docmd.OpenReport gRptName, acPreview, , ,"EmployeeID=" & Me.EmployeeID

3. then, call the Leban's function (I don't remember which option is for the file path)
Call ConvertReportToPDF(gRptName, , , True, False)

4. Close Access Report (DoCmd.Close.......)


thread for other details:
Lebans ReportToPDF solution Help
Sep 12 '08 #4
NeoPa
32,556 Expert Mod 16PB
Thanks for that pDog.

I may have to look into this tool myself sometime. The ability to handle that programmatically instead of via the operator (I have an Adobe driver) could prove very handy indeed :)
Sep 12 '08 #5
puppydogbuddy
1,923 Expert 1GB
Adrian,
You are welcome.

If you already have Adobe installed, and Access's native pdf add-in does not work, try using the ShellExecute method. It may not give you everything you want, but it is easy to implement.

The following example uses ShellExecute on a button click event. You need to replace the strPdfWriterPath with the path to the Acrobat.exe on your machine.

Expand|Select|Wrap|Line Numbers
  1. Private Sub PrintPdf_Click()
  2. Dim strPdfWriterPath As String
  3. Dim strFilePath As String
  4.  
  5. 'Open File
  6. 'strPdfWriterPath is the path to the application object
  7. 'strFilePath is the path to the file you want to open
  8.  
  9. strPdfWriterPath = "C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe"
  10. strFilePath = Me.FilePath
  11.  
  12. Call Shell(strPdfWriterPath & " " & strFilePath, vbMaximizedFocus)
  13.  
  14. End Sub
  15.  
Also, if you have MS Access 2007, it natively supports pdf. All you need to do is launch the Access report in preview mode and store the report name in variable, for example strAccessRptName.
Then, put the following code behind a button.

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourButton_Click()
  2. DoCmd.OutputTo acOutputReport, strAccessRptName, acFormatPDF, "c:PDF Reports\" & strAccessRptName & ".pdf", False
  3. End Sub
Sep 12 '08 #6
NeoPa
32,556 Expert Mod 16PB
I don't want to take the thread too much off track here pDog, but, although I have Adobe drivers installed on MY PC, the databse also needs to be run from others which don't (take some of the workload off me).

For that reason I'm interested in a solution where Adobe drivers aren't required. I'm hoping the Lebans solution might be what I'm after, so I'll look into it when I get some time available.

Thanks for all your help anyway.
Sep 12 '08 #7
ADezii
8,834 Expert 8TB
Adrian,
You are welcome.

If you already have Adobe installed, and Access's native pdf add-in does not work, try using the ShellExecute method. It may not give you everything you want, but it is easy to implement.

The following example uses ShellExecute on a button click event. You need to replace the strPdfWriterPath with the path to the Acrobat.exe on your machine.

Expand|Select|Wrap|Line Numbers
  1. Private Sub PrintPdf_Click()
  2. Dim strPdfWriterPath As String
  3. Dim strFilePath As String
  4.  
  5. 'Open File
  6. 'strPdfWriterPath is the path to the application object
  7. 'strFilePath is the path to the file you want to open
  8.  
  9. strPdfWriterPath = "C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe"
  10. strFilePath = Me.FilePath
  11.  
  12. Call Shell(strPdfWriterPath & " " & strFilePath, vbMaximizedFocus)
  13.  
  14. End Sub
  15.  
Also, if you have MS Access 2007, it natively supports pdf. All you need to do is launch the Access report in preview mode and store the report name in variable, for example strAccessRptName.
Then, put the following code behind a button.

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourButton_Click()
  2. DoCmd.OutputTo acOutputReport, strAccessRptName, acFormatPDF, "c:PDF Reports\" & strAccessRptName & ".pdf", False
  3. End Sub
Hello puppydogbuddy, forgive me if I'm wrong, but but I don't think what you are describing is the ShellExecute() API Function which is used to execute a File based solely on its Extension. Below I've posted the Declaration, Wrapper Function, and a sample Call to ShellExecute():
Expand|Select|Wrap|Line Numbers
  1. Declare Function ShellExecute Lib "shell32.dll" _
  2. Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _
  3. ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Expand|Select|Wrap|Line Numbers
  1. 'Wrapper Function
  2. Public Function Execute_Program(ByVal strFilePath As String, _
  3.     ByVal strParms As String, ByVal strDir As String) _
  4.     As Boolean
  5.  
  6. 'run program ' <R6>
  7. Dim hwndProgram As Integer
  8. hwndProgram = ShellExecute(0, "Open", strFilePath, strParms, strDir, 3)     '3 ==> Show Maximized
  9.  
  10. 'evaluate errors (if any)
  11. Select Case (hwndProgram)
  12.   Case 0
  13.     MsgBox "Insufficent system memory or corrupt program file.", 0, "Error running " & strFilePath
  14.       Execute_Program = False
  15.         Exit Function
  16.   Case 2
  17.     MsgBox "File not found.", 0, "Error running " & strFilePath
  18.       Execute_Program = False
  19.         Exit Function
  20.   Case 3
  21.     MsgBox "Invalid path.", 0, "Error running " & strFilePath
  22.       Execute_Program = False
  23.         Exit Function
  24.   Case 5
  25.     MsgBox "Sharing or Protection Error.", 0, "Error running " & strFilePath
  26.       Execute_Program = False
  27.         Exit Function
  28.   Case 6
  29.     MsgBox "Seperate data segments are required for each task.", 0, "Error running " & strFilePath
  30.       Execute_Program = False
  31.         Exit Function
  32.   Case 8
  33.     MsgBox "Insufficient memory to run the program.", 0, "Error running " & strFilePath
  34.       Execute_Program = False
  35.         Exit Function
  36.   Case 10
  37.     MsgBox "Incorrect Windows version.", 0, "Error running " & strFilePath
  38.       Execute_Program = False
  39.         Exit Function
  40.   Case 11
  41.     MsgBox "Invalid program file.", 0, "Error running " & strFilePath
  42.       Execute_Program = False
  43.         Exit Function
  44.   Case 12
  45.     MsgBox "Program file requires a different operating system.", 0, "Error running " & strFilePath
  46.       Execute_Program = False
  47.         Exit Function
  48.   Case 13
  49.     MsgBox "Program requires MS-DOS 4.0.", 0, "Error running " & strFilePath
  50.       Execute_Program = False
  51.         Exit Function
  52.   Case 14
  53.     MsgBox "Unknown program file type.", 0, "Error running " & strFilePath
  54.       Execute_Program = False
  55.         Exit Function
  56.   Case 15
  57.     MsgBox "Windows program does not support protected memory mode.", 0, "Error running " & strFilePath
  58.       Execute_Program = False
  59.         Exit Function
  60.   Case 16
  61.     MsgBox "Invalid use of data segments when loading a second instance of a program.", 0, "Error running " & strFilePath
  62.       Execute_Program = False
  63.         Exit Function
  64.   Case 19
  65.     MsgBox "Attempt to run a compressed program file.", 0, "Error running " & strFilePath
  66.       Execute_Program = False
  67.         Exit Function
  68.   Case 20
  69.     MsgBox "Invalid dynamic link library.", 0, "Error running " & strFilePath
  70.       Execute_Program = False
  71.         Exit Function
  72.   Case 21
  73.     MsgBox "Program requires Windows 32-bit extensions.", 0, "Error running " & strFilePath
  74.       Execute_Program = False
  75.         Exit Function
  76.   Case Else
  77. End Select
  78.   'All is well if we get to this point
  79.   Execute_Program = True
  80. End Function
Expand|Select|Wrap|Line Numbers
  1. 'Sample Call
  2. Dim blnRetVal As Boolean
  3. blnRetVal = Execute_Program("C:\Graphics\MyTest.jpg", "", "")
Sep 13 '08 #8
puppydogbuddy
1,923 Expert 1GB
ADezii,
Sorry, I didn't mean to confuse everyone, but my intent was to refer to the MS Access Shell VBA Command, not to the Windows Shell API. See the link below for a free tutorial on how the Shell VBA command can be used to start external programs (Acrobat, Word, etc).

http://www.bluemoosetech.com/microso...osoft%20Access
Sep 13 '08 #9
Hi PuppyDogBuddy,

Thank you very much it worked the way I exactly wanted.

Regards,
Ozair - Loving & Learning Ms Access
Sep 13 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: murl | last post by:
I have created a crystal report using crystal9.0, that is linked to a stored procedure in sql2k which requires 2 parameters to be met, a beggining date(smalldatetime) and a...
3
by: Don Wash | last post by:
Hi There! I've posted a few days back about this issue but no solutions has been found and that's why I'm re-posting this. I'm using built-in CrystalReport that comes with VS.NET 2003 to...
6
by: Woody Splawn | last post by:
I am using SQL Server 2000 as a back-end to a VS.net Client/Server app. In a certain report I use a view as part of the query spec. For the view, at present, I am querying for all the records in...
0
by: Helen | last post by:
I have a simple oledb dataset on one windows form in vb .net 2002 calling one column from oracle 7, results appear in a text box But, only the first results appears. Goal is to show all results...
2
by: Mitchell Vincent | last post by:
I would like to provide the end users of some of my software with the ability to customize the look and feel of certain documents for print and email. These documents all pull data from a database....
2
by: Dean Slindee | last post by:
I would like to pass multiple parameters from a VB.NET application to an existing Access 2003 application's reports (essentially using Access as a report writer where the reports already exist)....
1
by: Hexman | last post by:
Hello All, I have a new challenge. I've created a Crystal Report (version 10) and saved the file. Now from my program I want to print it to an Adobe PDF file. My question is: How do I pass...
0
by: PriyaManasarovar | last post by:
Can someone help how to pass parameters to a crystal report using a Crystal report object? I am using a console application & hence crystal report viewer cannot be used. And i need to pass the...
7
by: salzan | last post by:
I have a form in which I collect info from the user and then process various tables. Now, I need to call a report and pass two parameters to it so it’ll only select the desired records for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.