473,386 Members | 1,743 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,386 software developers and data experts.

using .Docmd. and parameter as number of copy,file name,query to access report

how can i pass parameter to print access report by giving parameter as Report File Name,Query,PrinterName,Number of copies to be print

my code is


Expand|Select|Wrap|Line Numbers
  1. Function fPrintRemoteReport(strMDB As String, _
  2.                                         strReport As String, _
  3.                                         rptPrinter As String, _
  4.                                         numCopies As Integer, _
  5.                                         Optional intView As Variant) _
  6.                                         As Boolean
  7.  
  8. Dim objAccess As Access.Application
  9.  
  10. Dim lngRet As Long
  11.     On Error GoTo fPrintRemoteReport_Err
  12.     strQuery = "SELECT Can1Z_Orders.* From Can1Z_Orders INNER JOIN ItemsPrinterTable ON Can1Z_Orders.UpsItemNumber = ItemsPrinterTable.UpsItemNumber " & _
  13.                " WHERE (((DateToPrint) Is Null) AND ((DetailInd)= 'pp' )) AND Can1Z_Orders.AutoID=" & GetAutoID()
  14.  
  15.     Set conn = modCommon.createConnection(App.Path & "\UPSThermalLabels.accdb")
  16.         conn.Execute ("Delete from  CSW_Orders_Temp ")
  17.     conn.Close
  18.     Set conn = Nothing
  19.  
  20.     Set conn = modCommon.createConnection(App.Path & "\UPSThermalLabels.accdb")
  21.     conn.Execute ("insert into CSW_Orders_Temp " & strQuery)
  22.  
  23.     conn.Close
  24.     Set conn = Nothing
  25.  
  26.     If Len(Dir(strMDB)) > 0 Then
  27.         Set objAccess = New Access.Application
  28.         With objAccess
  29.             .OpenCurrentDatabase strMDB
  30.             .DoCmd.SelectObject acReport, strReport, True
  31.             .DoCmd.PrintOut acPrintAll, , , , numCopies, False
  32.         End With
  33.         objAccess.Quit
  34.     Set objAccess = Nothing
  35.  
  36.     End If
  37.  
  38. fPrintRemoteReport_Exit:
  39.     On Error Resume Next
  40.     objAccess.Quit
  41.     Set objAccess = Nothing
  42.     Exit Function
  43. fPrintRemoteReport_Err:
  44.     fPrintRemoteReport = False
  45.     Select Case err.Number
  46.         Case 7866:
  47.             'mdb is already exclusively opened
  48.             MsgBox "The database you specified " & vbCrLf & strMDB & _
  49.                 vbCrLf & "is currently open in exclusive mode.  " & vbCrLf _
  50.                 & vbCrLf & "Please reopen in shared mode and try again", _
  51.                 vbExclamation + vbOKOnly, "Could not open database."
  52.         Case 2103:
  53.             'Report doesn't exist
  54.             MsgBox "The Report '" & strReport & _
  55.                         "' doesn't exist in the Database " _
  56.                         & vbCrLf & strMDB, _
  57.                         vbExclamation + vbOKOnly, "Report not found"
  58.         Case 7952:
  59.             fPrintRemoteReport = True
  60.     End Select
  61.     Resume fPrintRemoteReport_Exit
  62. End Function
  63.  
Aug 26 '10 #1
0 1118

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

Similar topics

0
by: Mark | last post by:
Hello, Access2000, Win98 I'm tring to use acCmdOLEDDELinks to automatically update an Excel object in an Access Report. Is it possible to use RunComand acCmdOLEDDELinks without user input? ...
1
by: mar10a | last post by:
I am trying to insert a .gif. file into an Access report - using Insert Picture. The original image is 8X11, but access changes the size to 4X6.5. When I change the size of the image in access...
1
by: gale | last post by:
I have an Access 2003 project. I need for users to be able to run a report and copy the report in Excel format to a web server. The problem is, they do not have write access to the web server. I...
0
by: Tuan Nguyen | last post by:
Hi all, I am writing asp.net with access database. I want to store text (messages) in the access database. However, the text data type in access database only allows me to store up to 255...
1
by: TommyG | last post by:
I have an Access report that I want to print with a standard "terms & conditions" page that is set up in word. How can I accopmplish this??
4
by: mcterborg | last post by:
Hello everyone, here is what I want to do. I have a ATI video card and it allows me to setup profiles for monitor configurations and so forth. The shortcut to activate one of these profiles looks...
1
by: mcfly1204 | last post by:
I am using the XslCompiledTransform class to convert .xml files into .html files. I would like to be able to use a string as part of the file name. For example: ...
1
by: CK | last post by:
Hi All, How do I parse a file path in Access for return the file name? Example c:\somefolder\somefolder\somefolder\somefolder\somefolder\somefolder\somefolder\someFile.xls I want to query a table...
185
by: jacob navia | last post by:
Hi We are rewriting the libc for the 64 bit version of lcc-win and we have added a new field in the FILE structure: char *FileName; fopen() will save the file name and an accessor function will...
2
by: francisjohn | last post by:
I am beginner for this MS-Access tool. I want to create PDF/MS-Word file from MS Access report. Whatever contents/values is there in MS-Access report, I need to convert these values to PDF/WORD...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.