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.
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.
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
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 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 :)
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. -
Private Sub PrintPdf_Click()
-
Dim strPdfWriterPath As String
-
Dim strFilePath As String
-
-
'Open File
-
'strPdfWriterPath is the path to the application object
-
'strFilePath is the path to the file you want to open
-
-
strPdfWriterPath = "C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe"
-
strFilePath = Me.FilePath
-
-
Call Shell(strPdfWriterPath & " " & strFilePath, vbMaximizedFocus)
-
-
End Sub
-
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. -
Private Sub YourButton_Click()
-
DoCmd.OutputTo acOutputReport, strAccessRptName, acFormatPDF, "c:PDF Reports\" & strAccessRptName & ".pdf", False
-
End Sub
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.
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. -
Private Sub PrintPdf_Click()
-
Dim strPdfWriterPath As String
-
Dim strFilePath As String
-
-
'Open File
-
'strPdfWriterPath is the path to the application object
-
'strFilePath is the path to the file you want to open
-
-
strPdfWriterPath = "C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe"
-
strFilePath = Me.FilePath
-
-
Call Shell(strPdfWriterPath & " " & strFilePath, vbMaximizedFocus)
-
-
End Sub
-
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. -
Private Sub YourButton_Click()
-
DoCmd.OutputTo acOutputReport, strAccessRptName, acFormatPDF, "c:PDF Reports\" & strAccessRptName & ".pdf", False
-
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(): - Declare Function ShellExecute Lib "shell32.dll" _
-
Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _
-
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
- 'Wrapper Function
-
Public Function Execute_Program(ByVal strFilePath As String, _
-
ByVal strParms As String, ByVal strDir As String) _
-
As Boolean
-
-
'run program ' <R6>
-
Dim hwndProgram As Integer
-
hwndProgram = ShellExecute(0, "Open", strFilePath, strParms, strDir, 3) '3 ==> Show Maximized
-
-
'evaluate errors (if any)
-
Select Case (hwndProgram)
-
Case 0
-
MsgBox "Insufficent system memory or corrupt program file.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 2
-
MsgBox "File not found.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 3
-
MsgBox "Invalid path.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 5
-
MsgBox "Sharing or Protection Error.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 6
-
MsgBox "Seperate data segments are required for each task.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 8
-
MsgBox "Insufficient memory to run the program.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 10
-
MsgBox "Incorrect Windows version.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 11
-
MsgBox "Invalid program file.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 12
-
MsgBox "Program file requires a different operating system.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 13
-
MsgBox "Program requires MS-DOS 4.0.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 14
-
MsgBox "Unknown program file type.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 15
-
MsgBox "Windows program does not support protected memory mode.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 16
-
MsgBox "Invalid use of data segments when loading a second instance of a program.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 19
-
MsgBox "Attempt to run a compressed program file.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 20
-
MsgBox "Invalid dynamic link library.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case 21
-
MsgBox "Program requires Windows 32-bit extensions.", 0, "Error running " & strFilePath
-
Execute_Program = False
-
Exit Function
-
Case Else
-
End Select
-
'All is well if we get to this point
-
Execute_Program = True
-
End Function
- 'Sample Call
-
Dim blnRetVal As Boolean
-
blnRetVal = Execute_Program("C:\Graphics\MyTest.jpg", "", "")
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
Hi PuppyDogBuddy,
Thank you very much it worked the way I exactly wanted.
Regards,
Ozair - Loving & Learning Ms Access
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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....
|
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)....
|
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...
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |