Connecting Tech Pros Worldwide Forums | Help | Site Map

Print Document direct from the form

Newbie
 
Join Date: Jun 2006
Location: Dammam-Saudi Arabia
Posts: 2
#1: Jun 17 '06
Hello

I am finding a problem in code to generate an output direct from Access Form. I am explaining my problem with the help of example

I designed an invoice form on the MS Access and designed this document in MS Access Report designer and Crystal Report as well. What i need to do if i am on MS Access form and i am on invoice # 100 when i press "Print" button then from report invoice # 100 will be print.

Kindly send me a code which will use in print button.

Hafeez

PEB's Avatar
PEB PEB is offline
Expert
 
Join Date: Aug 2006
Location: Bulgaria
Posts: 1,380
#2: Sep 3 '06

re: Print Document direct from the form


You need to use:
1. docmd.openreport command for more info see help in Access about it

2. You need to change the SQL passed on the report! You have to introduce an filter that shows only the current record! This filter you can pass it bythe command docmd.openreport

The code as well as U do Copy Paste I can't do it without information about your Tables, queries, forms and reports that U use!

U have only to see the use of docmd.openreport as Macro or Code as U want!
msquared's Avatar
Administrator
 
Join Date: Aug 2006
Location: Dublin, Ireland
Posts: 10,880
#3: Sep 3 '06

re: Print Document direct from the form


You need to set criteria for opening the report same as with forms.

Expand|Select|Wrap|Line Numbers
  1. Private Sub butPrint_Click()
  2. Dim stDocName As String
  3. Dim stLinkCriteria As String
  4.  
  5.     stDocName = "ReportName"
  6.     stLinkCriteria = "[InvoiceNo]=" & Me.[InvoiceNo]
  7.     DoCmd.OpenReport stDocName, acViewNormal, , stLinkCriteria
  8.  
  9. End Sub
  10.  
Quote:

Originally Posted by ahafeez

Hello

I am finding a problem in code to generate an output direct from Access Form. I am explaining my problem with the help of example

I designed an invoice form on the MS Access and designed this document in MS Access Report designer and Crystal Report as well. What i need to do if i am on MS Access form and i am on invoice # 100 when i press "Print" button then from report invoice # 100 will be print.

Kindly send me a code which will use in print button.

Hafeez

Reply