Slammer2
See below for an exerpt from Microsoft Knowledge Base on how to print a report from your records in a filter by form. The link takes you to the article where you can download a sample db demonstrating this procedure.
Good Luck :-9
This example uses the sample database Northwind.mdb. The technique involves creating a new form and a new report. The form uses event procedures to apply a filter and to open the new report. The report uses the Filter property to apply the same filter that is used in the form.
Open the sample database Northwind.mdb.
Use the AutoReport: Tabular Wizard to create a new report based on the Customers table. Close and save the report as rptCustomers.
Use the AutoForm: Tabular Wizard to create a new form based on the Customers table. Close and save the form as frmFilterForm.
Open frmFilterForm in Design view. Increase the size of the form footer section so that it can hold three command buttons.
Create a command button in the form footer and set its properties as follows:
Name: cmdOpenReport
Caption: Open Report
OnClick: [Event Procedure]
Set the OnClick [Event Procedure] as follows:
Private Sub cmdOpenReport_Click()
If Me.Filter = "" Then
MsgBox "Apply a filter to the form first"
Else
DoCmd.OpenReport "rptCustomers", A_PREVIEW, , Me.Filter
End If
End Sub
Create a second button in the form footer and set its properties as follows:
Name: cmdClearFilter
Caption: Clear Filter
OnClick: [Event Procedure]
Set the OnClick [Event Procedure] as follows:
Private Sub cmdClearFilter_Click()
Me.Filter = ""
End Sub
Create a third button in the form footer and set its properties as follows:
Name: cmdClose
Caption: Close
OnClick: [Event Procedure]
Set the OnClick [Event Procedure] as follows:
Private Sub cmdClose_Click()
DoCmd.Close acForm, Me.Form.Name
End Sub
Set the following properties for the frmFilterForm form:
OnOpen: [Event Procedure]
OnClose: [Event Procedure]
Set the form's OnOpen [Event Procedure] as follows:
Private Sub Form_Open(Cancel as Integer)
Me.Filter = ""
End Sub
Set the form's OnClose [Event Procedure] as follows:
Private Sub Form_Close()
DoCmd.Close acReport, "rptCustomers"
End Sub
Switch the form to Form view.
On the toolbar, click the Filter By Form button to set a filter, and then click the Apply Filter button to apply the filter.
Click the Open Report button on the form. A report should appear with the same filter that was applied to the form.