| Home | Consulting | Training | Database | Web Design | Helpline |

< Back

 

Table of Contents

Print only the current record

Email a Report as a Snapshot

 

Creating clear and comprehensive reports to display your data, is critical to managing information in a database.  These tips will help you streamline your ability to visualize your data so you can make better management decisions.

Print only the current record.

The following procedure will print only the record selected on your form

  1. Open your form in Design view. Add a command button to the form, and then set the following command button properties:

Name: cmdPrintRecord
Caption: Print Record
OnClick: [Event Procedure] 
  1. Set the OnClick property to the following event procedure:

'******start code ******
Private Sub cmdPrintRecord_Click()
Dim strReportName As String
Dim strCriteria As String
strReportName = "Your Report Name"
strCriteria = "[CustomerID]='" & Me![CustomerID] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End Sub 
'******End code ******
  1. Change [CustomerID] to the name of your primary key used for the form. 

  2. Open the form in Form view, and then click Print Record. Note that the report preview is limited to the current record from the Customer form.

[Return to top]


Email a Snapshot of your reports.

Place this code in a OnClick event procedure of a command button on a form.  When you click it, a dialog box opens letting you choose to either print or email the report.

 

 ‘*******Start Code ***********

Private Sub Command_Click()

On Error GoTo Err_ Command _Click

 

    Dim stDocName As String

    Dim stEmail As String

    Dim stText As String

    Dim stSubj As String

    Dim Response As Integer

 

    stDocName = "Your Report Name"

    stText = "Place the text of your message here."

    stSubj = "Place a brief subject here."

   

   If MsgBox("Click 'Yes' to Email or 'No to print the report?", vbYesNo, _

      "Reports") = vbNo Then

                 DoCmd.OpenReport stDocName, acPreview

   

  Else

      stEmail = "FirstName;SecondName"     'Enter email names; separate with semi-colons

      DoCmd.OpenReport stDocName, acViewPreview

      DoCmd.SendObject acReport, stDocName, "SnapshotFormat (*.SNP)", stEmail, , , stSubj, stText

      DoCmd.Close acReport, stDocName

    

    End If

Exit_Command_Click:

    Exit Sub

 

Err_ Command _Click:

    MsgBox Err.Description

    Resume Exit_ Command _Click

   

End Sub

*******End Code ***********

 

[Return to top]


 

 

Designed by: Business Information Solutions, P.O. Box 987, Melville, NY 11747 - Tel. 631.956.1392