One basic method is like this
Let's say that the form which you are using to enter your data, contains a
number field, CustomerID and this field is the one by which you want to
filter your report- RptReceipt
In the form's design view, add a Command button and choose Report
Operations, Preview Report
Choose your report.
Right click on the command button and go to Properties.
On the Events tab click just right of On Click to open a code page
You will see something like this:
Private Sub CommandButtonsName_Click()
On Error GoTo Err_CommandButtonsName_Click
Dim stDocName As String
stDocName = "RptReceipt"
DoCmd.OpenReport stDocName, acPreview
Exit_CommandButtonsName_Click:
Exit Sub
Err_CommandButtonsName_Click:
MsgBox Err.Description
Resume Exit_CommandButtonsName_Click
End Sub
Edit the line that starts with DoCmd so that it now reads 1 line which says
DoCmd.OpenReport stDocName, acPreview, , "[CustomerID]=" & Me.[CustomerID]
(note there are 2 commas after acPreview)
The Me.CustomerID means that the code is looking at what is in the
CustomerID field in your form (that's the Me bit) and matching it with
CustomerID in your report
Substitue the words RptReciept and CustomerID with the names of your real
report and the field.by which you want to filter
Evi