Code.GeekInterview.com
 
Code Samples MS Access
 

Show Print Preview Option before printing


Code ResourceAuthor: Rajani  

Difficulty Level:

Published: 5th Aug 2007   Read: 5318 times  

Filed in: MS Access
Add Comment


 

 

Sponsored Links


 

 

The following code shows Print Preview Option, so that the user can opt to see the preview on screen or directly send it to the printer. Following is generic code which needs report name 'PRepName' and 'PRepCond' as its parameters. In the present context PRepName and PRepCond are set as Global Variables. This function when placed in Module, can be called from any form -> onButtonClick even.

 


Sample Code
  1.  
  2. Public Function FBtnPrint()
  3. On Error Resume Next
  4.     Dim Response As Integer
  5.     If IsNull(PRepName) = True Or Len(RTrim(LTrim(PRepName))) = 0 Or PRepName = "Null" Then
  6.         MsgBox "Sorry! Report Option is Currently Not Available for this Form...", vbExclamation, "User Alert"
  7.     Else
  8.         Response = MsgBox("Do You Wish To See Preview?", vbQuestion + vbYesNo + vbDefaultButton2, "User Alert")
  9.         If PRepCond <> "Null" Then
  10.             If Len(LTrim(RTrim(PRepCond))) > 0 Then
  11.                 If Response = 6 Then DoCmd.OpenReport PRepName, acViewPreview, , PRepCond
  12.                 If Response <> 6 Then DoCmd.OpenReport PRepName, acViewNormal, , PRepCond
  13.             Else
  14.                 If Response = 6 Then DoCmd.OpenReport PRepName, acViewPreview
  15.                 If Response <> 6 Then DoCmd.OpenReport PRepName, acViewNormal
  16.             End If
  17.         Else
  18.             If Response = 6 Then DoCmd.OpenReport PRepName, acViewPreview
  19.             If Response <> 6 Then DoCmd.OpenReport PRepName, acViewNormal
  20.         End If
  21.     End If
  22. End Function
  23.  
Copyright GeekInterview.com


Next Article: Recover Tables Data from Corrupt MS Access Database


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Comments

i like it
Comment posted by: vivek tripathi on 2010-05-14T05:14:25

Popular Coders

# Coder NameHits
1. Lokesh M12071
2. Shivanna6704
3. Rajani5319

Active Coders

# Coder NameCodes
1. Shivanna2
2. Lokesh M2
3. Rajani1

Refined Tags